本文整理了Java中org.bitcoinj.core.Transaction.isFinal()
方法的一些代码示例,展示了Transaction.isFinal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.isFinal()
方法的具体详情如下:
包路径:org.bitcoinj.core.Transaction
类名称:Transaction
方法名:isFinal
[英]Returns true if this transaction is considered finalized and can be placed in a block. Non-finalized transactions won't be included by miners and can be replaced with newer versions using sequence numbers. This is useful in certain types of contracts, such as micropayment channels.
Note that currently the replacement feature is disabled in Bitcoin Core and will need to be re-activated before this functionality is useful.
[中]如果此事务被视为已完成且可以放置在块中,则返回true。矿工不包括未完成的交易,可以用使用序列号的更新版本替换。这在某些类型的contracts中很有用,例如小额支付渠道。
请注意,比特币核心中的替换功能目前已禁用,需要重新激活才能使用该功能。
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
@Nullable
private Result analyzeIsFinal() {
// Transactions we create ourselves are, by definition, not at risk of double spending against us.
if (tx.getConfidence().getSource() == TransactionConfidence.Source.SELF)
return Result.OK;
// We consider transactions that opt into replace-by-fee at risk of double spending.
if (tx.isOptInFullRBF()) {
nonFinal = tx;
return Result.NON_FINAL;
}
if (wallet == null)
return null;
final int height = wallet.getLastBlockSeenHeight();
final long time = wallet.getLastBlockSeenTimeSecs();
// If the transaction has a lock time specified in blocks, we consider that if the tx would become final in the
// next block it is not risky (as it would confirm normally).
final int adjustedHeight = height + 1;
if (!tx.isFinal(adjustedHeight, time)) {
nonFinal = tx;
return Result.NON_FINAL;
}
for (Transaction dep : dependencies) {
if (!dep.isFinal(adjustedHeight, time)) {
nonFinal = dep;
return Result.NON_FINAL;
}
}
return Result.OK;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
@Nullable
private Result analyzeIsFinal() {
// Transactions we create ourselves are, by definition, not at risk of double spending against us.
if (tx.getConfidence().getSource() == TransactionConfidence.Source.SELF)
return Result.OK;
// We consider transactions that opt into replace-by-fee at risk of double spending.
if (tx.isOptInFullRBF()) {
nonFinal = tx;
return Result.NON_FINAL;
}
if (wallet == null)
return null;
final int height = wallet.getLastBlockSeenHeight();
final long time = wallet.getLastBlockSeenTimeSecs();
// If the transaction has a lock time specified in blocks, we consider that if the tx would become final in the
// next block it is not risky (as it would confirm normally).
final int adjustedHeight = height + 1;
if (!tx.isFinal(adjustedHeight, time)) {
nonFinal = tx;
return Result.NON_FINAL;
}
for (Transaction dep : dependencies) {
if (!dep.isFinal(adjustedHeight, time)) {
nonFinal = dep;
return Result.NON_FINAL;
}
}
return Result.OK;
}
代码示例来源:origin: greenaddress/GreenBits
@Nullable
private Result analyzeIsFinal() {
// Transactions we create ourselves are, by definition, not at risk of double spending against us.
if (tx.getConfidence().getSource() == TransactionConfidence.Source.SELF)
return Result.OK;
// We consider transactions that opt into replace-by-fee at risk of double spending.
if (tx.isOptInFullRBF()) {
nonFinal = tx;
return Result.NON_FINAL;
}
if (wallet == null)
return null;
final int height = wallet.getLastBlockSeenHeight();
final long time = wallet.getLastBlockSeenTimeSecs();
// If the transaction has a lock time specified in blocks, we consider that if the tx would become final in the
// next block it is not risky (as it would confirm normally).
final int adjustedHeight = height + 1;
if (!tx.isFinal(adjustedHeight, time)) {
nonFinal = tx;
return Result.NON_FINAL;
}
for (Transaction dep : dependencies) {
if (!dep.isFinal(adjustedHeight, time)) {
nonFinal = dep;
return Result.NON_FINAL;
}
}
return Result.OK;
}
代码示例来源:origin: HashEngineering/dashj
@Nullable
private Result analyzeIsFinal() {
// Transactions we create ourselves are, by definition, not at risk of double spending against us.
if (tx.getConfidence().getSource() == TransactionConfidence.Source.SELF)
return Result.OK;
// Relative time-locked transactions are risky too. We can't check the locks because usually we don't know the
// spent outputs (to know when they were created).
if (tx.hasRelativeLockTime()) {
nonFinal = tx;
return Result.NON_FINAL;
}
if (wallet == null)
return null;
final int height = wallet.getLastBlockSeenHeight();
final long time = wallet.getLastBlockSeenTimeSecs();
// If the transaction has a lock time specified in blocks, we consider that if the tx would become final in the
// next block it is not risky (as it would confirm normally).
final int adjustedHeight = height + 1;
if (!tx.isFinal(adjustedHeight, time)) {
nonFinal = tx;
return Result.NON_FINAL;
}
for (Transaction dep : dependencies) {
if (!dep.isFinal(adjustedHeight, time)) {
nonFinal = dep;
return Result.NON_FINAL;
}
}
return Result.OK;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
checkNotNull(block.transactions);
for (Transaction tx : block.transactions)
if (!tx.isFinal(storedPrev.getHeight() + 1, block.getTimeSeconds()))
throw new VerificationException("Block contains non-final transaction");
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
checkNotNull(block.transactions);
for (Transaction tx : block.transactions)
if (!tx.isFinal(storedPrev.getHeight() + 1, block.getTimeSeconds()))
throw new VerificationException("Block contains non-final transaction");
代码示例来源:origin: greenaddress/GreenBits
checkNotNull(block.transactions);
for (Transaction tx : block.transactions)
if (!tx.isFinal(storedPrev.getHeight() + 1, block.getTimeSeconds()))
throw new VerificationException("Block contains non-final transaction");
代码示例来源:origin: HashEngineering/dashj
checkNotNull(block.transactions);
for (Transaction tx : block.transactions)
if (!tx.isFinal(storedPrev.getHeight() + 1, block.getTimeSeconds()))
throw new VerificationException("Block contains non-final transaction");
代码示例来源:origin: greenaddress/GreenBits
addOnlyInputToTransaction(tx, out18, 0);
b62.addTransaction(tx);
checkState(!tx.isFinal(chainHeadHeight + 17, b62.block.getTimeSeconds()));
checkState(!b63.block.getTransactions().get(0).isFinal(chainHeadHeight + 17, b63.block.getTimeSeconds()));
内容来源于网络,如有侵权,请联系作者删除!