固定转入 1 TRX,费用为“本金折价 USDT + 固定服务费”。

下单冻结资金,链上独立确认后扣款并记录供应商收入。
支持 NILE、主网独立配置;未知交易不退款、不重复构建。
已补充清晰注释、分阶段脱敏日志和已确认交易哈希展示。
This commit is contained in:
lu7213 committed 2026-10-29 19:52:51 -04:00
1 parent 1286f0df81
commit fbc72b5b57
24 files changed
+851 -27

No files matched your search

@@ -208,6 +208,9 @@ public class RentalChain {
require(contracts.size() == 1, "交易合约数量异常");
JsonNode contract = contracts.get(0);
JsonNode value = contract.path("parameter").path("value");
if (RentalOnchain.TASK_TYPE.equals(text(task, "task_type"))) {
return verifyOnchain(task, tx, receipt, contract, value, owner, receiver, height);
}
String expected =
"DELEGATE".equals(text(task, "task_type"))
? "DelegateResourceContract"
@@ -298,6 +301,34 @@ public class RentalChain {
return ApiWrapper.toHex(ApiWrapper.parseAddress(address));
}
/** 不信任节点 RESULT:在指定网络独立核对原生单合约、owner、to、固定金额及确认回执。 */
private Map<String, Object> verifyOnchain(Map<String, Object> task, JsonNode tx, JsonNode receipt,
JsonNode contract, JsonNode value, String owner, String receiver, long height) {
long timestamp = tx.path("raw_data").path("timestamp").asLong(-1);
require(tx.path("txID").asText().equalsIgnoreCase(receipt.path("id").asText())
&& timestamp >= time(task.get("signed_at")).toEpochMilli() - 5000
&& timestamp <= time(task.get("deadline")).toEpochMilli(),
"转账不在任务授权时间内或回执哈希不符,保留冻结核对");
require("TransferContract".equals(contract.path("type").asText())
&& contract.path("Permission_id").asInt(0) == 0
&& hexAddress(owner).equalsIgnoreCase(value.path("owner_address").asText())
&& hexAddress(receiver).equalsIgnoreCase(value.path("to_address").asText())
&& value.path("amount").asLong(-1) == RentalOnchain.TRANSFER_SUN
&& number(task, "delegate_sun") == RentalOnchain.TRANSFER_SUN
&& "TRX".equals(text(task, "resource_type")), "链上转账与固定1TRX任务不符");
require(tx.path("ret").size() == 1 && receipt.path("blockTimeStamp").asLong() > 0,
"转账执行回执缺失,保留冻结资金");
if (!"SUCCESS".equals(tx.path("ret").get(0).path("contractRet").asText())) {
return map("status", "FAILED");
}
require(!"FAILED".equals(receipt.path("result").asText()), "回执状态冲突,需人工核对");
log.info("地址上链证明通过 taskId={} network={} txId={} blockHeight={} transferSun={}",
task.get("id"), task.get("network"), tx.path("txID").asText(), height, RentalOnchain.TRANSFER_SUN);
return map("status", "CONFIRMED", "block_height", height, "block_time",
java.time.LocalDateTime.ofInstant(java.time.Instant.ofEpochMilli(receipt.path("blockTimeStamp").asLong()),
java.time.ZoneOffset.UTC));
}
/** 自动充值定位唯一匹配日志;不信任支付平台传入的日志索引,兼用人工充值去重键。 */
public Map<String, Object> paymentTransfer(String network, String txId, String address,
BigDecimal expected, long createdAt, long expiresAt) {