以太坊最新漏洞首发!重大发现!以太坊Token转账有效性标识字段的含义调整或将引发新一轮对交易站的攻击!
参考:https://www.douban.com/group/topic/125523381/
hash失败案例参考:https://blog.csdn.net/weixin_43343144/article/details/101052060
// 等待hash交易完成最终写入区块返回收据【唯一确保交易100%完成的凭据】
waitForTransactionFinish (transactionHash, successFunc = null, failFunc = null) {
return Utils.tryCatchGlobalPromise(async (resolve, reject) => {
// ethers.js库官方说明:waitForTransaction等价于provider.once(transactionHash,callbackFunc)仅一次监听!
// 【非常重要】这里不能使用await调用【必须异步执行,同步的话会出现无限期等待的情况】
return this.active_wallet.provider.waitForTransaction(transactionHash).then((transactionReceipt) => {
// 以太坊交易成功的唯一判断依据:status为1,牵涉到转账的话logs数组一定是有event事件日志数据
console.log("监听当前hash挖掘的收据交易状态【为1代表交易成功、为0代表交易失败】transactionReceipt.status:", transactionReceipt.status);
console.log("监听当前hash挖掘的收据交易event事件日志transactionReceipt.logs:", transactionReceipt.logs);
if (transactionReceipt.status === 1 && transactionReceipt.logs.length !== 0) {
Utils.isFunction(successFunc) ? successFunc(transactionReceipt) : null;
return resolve(transactionReceipt);
}
Utils.isFunction(failFunc) ? failFunc() : null;
return resolve(null);
}).catch((error) => {
console.log(`监听的当前hash:${transactionHash}失败,错误error:${error}`);
console.log("注意:本次hash挖掘失败,不会更新任何数据,下一轮会再次监听此hash,知道hash交易成功得到收据凭证transactionReceipt");
return resolve(null);
});
});
}