本文整理了Java中org.bitcoinj.core.Block.bitcoinSerialize()
方法的一些代码示例,展示了Block.bitcoinSerialize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.bitcoinSerialize()
方法的具体详情如下:
包路径:org.bitcoinj.core.Block
类名称:Block
方法名:bitcoinSerialize
[英]Special handling to check if we have a valid byte array for both header and transactions
[中]检查头和事务是否有有效字节数组的特殊处理
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
public int getOptimalEncodingMessageSize() {
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
optimalEncodingMessageSize = bitcoinSerialize().length;
return optimalEncodingMessageSize;
}
代码示例来源:origin: HashEngineering/dashj
public int getOptimalEncodingMessageSize() {
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
optimalEncodingMessageSize = bitcoinSerialize().length;
return optimalEncodingMessageSize;
}
代码示例来源:origin: greenaddress/GreenBits
public int getOptimalEncodingMessageSize() {
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
optimalEncodingMessageSize = bitcoinSerialize().length;
return optimalEncodingMessageSize;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
public int getOptimalEncodingMessageSize() {
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
optimalEncodingMessageSize = bitcoinSerialize().length;
return optimalEncodingMessageSize;
}
代码示例来源:origin: greenaddress/GreenBits
private Block roundtrip(Block b2) throws ProtocolException {
return PARAMS.getDefaultSerializer().makeBlock(b2.bitcoinSerialize());
}
代码示例来源:origin: greenaddress/GreenBits
@Override
public boolean add(Rule element) {
if (outStream != null && element instanceof BlockAndValidity) {
try {
outStream.write((int) (params.getPacketMagic() >>> 24));
outStream.write((int) (params.getPacketMagic() >>> 16));
outStream.write((int) (params.getPacketMagic() >>> 8));
outStream.write((int) params.getPacketMagic());
byte[] block = ((BlockAndValidity)element).block.bitcoinSerialize();
byte[] length = new byte[4];
Utils.uint32ToByteArrayBE(block.length, length, 0);
outStream.write(Utils.reverseBytes(length));
outStream.write(block);
((BlockAndValidity)element).block = null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return super.add(element);
}
};
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testBitcoinSerialization() throws Exception {
// We have to be able to reserialize everything exactly as we found it for hashing to work. This test also
// proves that transaction serialization works, along with all its subobjects like scripts and in/outpoints.
//
// NB: This tests the bitcoin serialization protocol.
Block block = PARAMS.getDefaultSerializer().makeBlock(blockBytes);
assertTrue(Arrays.equals(blockBytes, block.bitcoinSerialize()));
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testHeaderParse() throws Exception {
Block block = PARAMS.getDefaultSerializer().makeBlock(blockBytes);
Block header = block.cloneAsHeader();
Block reparsed = PARAMS.getDefaultSerializer().makeBlock(header.bitcoinSerialize());
assertEquals(reparsed, header);
}
代码示例来源:origin: greenaddress/GreenBits
bs.serialize(b1, bos);
b1BytesWithHeader = bos.toByteArray();
b1Bytes = b1.bitcoinSerialize();
代码示例来源:origin: greenaddress/GreenBits
NetworkParameters params = UnitTestParams.get();
Block block = params.getGenesisBlock().createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, new ECKey().getPubKey(), Block.BLOCK_HEIGHT_GENESIS);
assertEquals(block.bitcoinSerialize().length, block.length);
final int origBlockLen = block.length;
Transaction tx = new Transaction(params);
代码示例来源:origin: greenaddress/GreenBits
b56 = params.getDefaultSerializer().makeBlock(b57.block.bitcoinSerialize());
} catch (ProtocolException e) {
throw new RuntimeException(e); // Cannot happen.
b56p2 = params.getDefaultSerializer().makeBlock(b57p2.block.bitcoinSerialize());
} catch (ProtocolException e) {
throw new RuntimeException(e); // Cannot happen.
checkState(Arrays.equals(stream.toByteArray(), b64.bitcoinSerialize()));
checkState(b64.getOptimalEncodingMessageSize() == b64Original.block.getMessageSize());
Block b71 = params.getDefaultSerializer().makeBlock(b72.block.bitcoinSerialize());
b71.addTransaction(b72.block.getTransactions().get(2));
checkState(b71.getHash().equals(b72.getHash()));
内容来源于网络,如有侵权,请联系作者删除!