本文整理了Java中org.bitcoinj.core.Transaction.checkCoinBaseHeight()
方法的一些代码示例,展示了Transaction.checkCoinBaseHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.checkCoinBaseHeight()
方法的具体详情如下:
包路径:org.bitcoinj.core.Transaction
类名称:Transaction
方法名:checkCoinBaseHeight
[英]Check block height is in coinbase input script, for use after BIP 34 enforcement is enabled.
[中]检查coinbase输入脚本中的块高度,以便在启用BIP 34强制后使用。
代码示例来源:origin: HashEngineering/dashj
/**
* Verify the transactions on a block.
*
* @param height block height, if known, or -1 otherwise. If provided, used
* to validate the coinbase input script of v2 and above blocks.
* @throws VerificationException if there was an error verifying the block.
*/
private void checkTransactions(final int height, final EnumSet<VerifyFlag> flags)
throws VerificationException {
// The first transaction in a block must always be a coinbase transaction.
if (!transactions.get(0).isCoinBase())
throw new VerificationException("First tx is not coinbase");
if (flags.contains(Block.VerifyFlag.HEIGHT_IN_COINBASE) && height >= BLOCK_HEIGHT_GENESIS) {
transactions.get(0).checkCoinBaseHeight(height);
}
// The rest must not be.
for (int i = 1; i < transactions.size(); i++) {
if (transactions.get(i).isCoinBase())
throw new VerificationException("TX " + i + " is coinbase when it should not be.");
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Verify the transactions on a block.
*
* @param height block height, if known, or -1 otherwise. If provided, used
* to validate the coinbase input script of v2 and above blocks.
* @throws VerificationException if there was an error verifying the block.
*/
private void checkTransactions(final int height, final EnumSet<VerifyFlag> flags)
throws VerificationException {
// The first transaction in a block must always be a coinbase transaction.
if (!transactions.get(0).isCoinBase())
throw new VerificationException("First tx is not coinbase");
if (flags.contains(Block.VerifyFlag.HEIGHT_IN_COINBASE) && height >= BLOCK_HEIGHT_GENESIS) {
transactions.get(0).checkCoinBaseHeight(height);
}
// The rest must not be.
for (int i = 1; i < transactions.size(); i++) {
if (transactions.get(i).isCoinBase())
throw new VerificationException("TX " + i + " is coinbase when it should not be.");
}
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Verify the transactions on a block.
*
* @param height block height, if known, or -1 otherwise. If provided, used
* to validate the coinbase input script of v2 and above blocks.
* @throws VerificationException if there was an error verifying the block.
*/
private void checkTransactions(final int height, final EnumSet<VerifyFlag> flags)
throws VerificationException {
// The first transaction in a block must always be a coinbase transaction.
if (!transactions.get(0).isCoinBase())
throw new VerificationException("First tx is not coinbase");
if (flags.contains(Block.VerifyFlag.HEIGHT_IN_COINBASE) && height >= BLOCK_HEIGHT_GENESIS) {
transactions.get(0).checkCoinBaseHeight(height);
}
// The rest must not be.
for (int i = 1; i < transactions.size(); i++) {
if (transactions.get(i).isCoinBase())
throw new VerificationException("TX " + i + " is coinbase when it should not be.");
}
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Verify the transactions on a block.
*
* @param height block height, if known, or -1 otherwise. If provided, used
* to validate the coinbase input script of v2 and above blocks.
* @throws VerificationException if there was an error verifying the block.
*/
private void checkTransactions(final int height, final EnumSet<VerifyFlag> flags)
throws VerificationException {
// The first transaction in a block must always be a coinbase transaction.
if (!transactions.get(0).isCoinBase())
throw new VerificationException("First tx is not coinbase");
if (flags.contains(Block.VerifyFlag.HEIGHT_IN_COINBASE) && height >= BLOCK_HEIGHT_GENESIS) {
transactions.get(0).checkCoinBaseHeight(height);
}
// The rest must not be.
for (int i = 1; i < transactions.size(); i++) {
if (transactions.get(i).isCoinBase())
throw new VerificationException("TX " + i + " is coinbase when it should not be.");
}
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testCoinbaseHeightCheck() throws VerificationException {
// Coinbase transaction from block 300,000
final byte[] transactionBytes = HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803e09304062f503253482f0403c86d53087ceca141295a00002e522cfabe6d6d7561cf262313da1144026c8f7a43e3899c44f6145f39a36507d36679a8b7006104000000000000000000000001c8704095000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000");
final int height = 300000;
final Transaction transaction = PARAMS.getDefaultSerializer().makeTransaction(transactionBytes);
transaction.checkCoinBaseHeight(height);
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Test a coinbase transaction whose script has nonsense after the block height.
* See https://github.com/bitcoinj/bitcoinj/issues/1097
*/
@Test
public void testCoinbaseHeightCheckWithDamagedScript() throws VerificationException {
// Coinbase transaction from block 224,430
final byte[] transactionBytes = HEX.decode(
"010000000100000000000000000000000000000000000000000000000000000000"
+ "00000000ffffffff3b03ae6c0300044bd7031a0400000000522cfabe6d6d0000"
+ "0000000000b7b8bf0100000068692066726f6d20706f6f6c7365727665726aac"
+ "1eeeed88ffffffff01e0587597000000001976a91421c0d001728b3feaf11551"
+ "5b7c135e779e9f442f88ac00000000");
final int height = 224430;
final Transaction transaction = PARAMS.getDefaultSerializer().makeTransaction(transactionBytes);
transaction.checkCoinBaseHeight(height);
}
内容来源于网络,如有侵权,请联系作者删除!