本文整理汇总了Java中org.ethereum.util.ByteUtil.bytesToBigInteger方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.bytesToBigInteger方法的具体用法?Java ByteUtil.bytesToBigInteger怎么用?Java ByteUtil.bytesToBigInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.util.ByteUtil
的用法示例。
在下文中一共展示了ByteUtil.bytesToBigInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rlpParse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public synchronized void rlpParse() {
if (parsed) return;
try {
RLPList decodedTxList = RLP.decode2(rlpEncoded);
RLPList transaction = (RLPList) decodedTxList.get(0);
// Basic verification
if (transaction.size() > 9 ) throw new RuntimeException("Too many RLP elements");
for (RLPElement rlpElement : transaction) {
if (!(rlpElement instanceof RLPItem))
throw new RuntimeException("Transaction RLP elements shouldn't be lists");
}
this.nonce = transaction.get(0).getRLPData();
this.gasPrice = transaction.get(1).getRLPData();
this.gasLimit = transaction.get(2).getRLPData();
this.receiveAddress = transaction.get(3).getRLPData();
this.value = transaction.get(4).getRLPData();
this.data = transaction.get(5).getRLPData();
// only parse signature in case tx is signed
if (transaction.get(6).getRLPData() != null) {
byte[] vData = transaction.get(6).getRLPData();
BigInteger v = ByteUtil.bytesToBigInteger(vData);
this.chainId = extractChainIdFromV(v);
byte[] r = transaction.get(7).getRLPData();
byte[] s = transaction.get(8).getRLPData();
this.signature = ECDSASignature.fromComponents(r, s, getRealV(v));
} else {
logger.debug("RLP encoded tx is not signed!");
}
this.parsed = true;
this.hash = getHash();
} catch (Exception e) {
throw new RuntimeException("Error on parsing RLP", e);
}
}
示例2: validate
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private String validate(Transaction tx) {
try {
tx.verify();
} catch (Exception e) {
return String.format("Invalid transaction: %s", e.getMessage());
}
if (config.getMineMinGasPrice().compareTo(ByteUtil.bytesToBigInteger(tx.getGasPrice())) > 0) {
return "Too low gas price for transaction: " + ByteUtil.bytesToBigInteger(tx.getGasPrice());
}
return null;
}