/** * Constructs a block object from the Bitcoin wire format. * @deprecated Use {@link BitcoinSerializer#makeBlock(byte[])} instead. */ @Deprecated public Block(NetworkParameters params, byte[] payloadBytes) throws ProtocolException { super(params, payloadBytes, 0, params.getDefaultSerializer(), payloadBytes.length); }
/** * Constructs a block object from the Bitcoin wire format. * @deprecated Use {@link BitcoinSerializer#makeBlock(byte[])} instead. */ @Deprecated public Block(NetworkParameters params, byte[] payloadBytes) throws ProtocolException { super(params, payloadBytes, 0, params.getDefaultSerializer(), payloadBytes.length); }
/** * Set the serializer for this message when deserialized by Java. */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (null != params) { this.serializer = params.getDefaultSerializer(); } } }
/** * Set the serializer for this message when deserialized by Java. */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (null != params) { this.serializer = params.getDefaultSerializer(); } } }
/** * Constructs a block object from the Bitcoin wire format. * @deprecated Use {@link BitcoinSerializer#makeBlock(byte[])} instead. */ @Deprecated public Block(NetworkParameters params, byte[] payloadBytes) throws ProtocolException { super(params, payloadBytes, 0, params.getDefaultSerializer(), payloadBytes.length); }
/** * Set the serializer for this message when deserialized by Java. */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (null != params) { this.serializer = params.getDefaultSerializer(); } } }
/** * Set the serializer for this message when deserialized by Java. */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (null != params) { this.serializer = params.getDefaultSerializer(); } } }
public PeerSocketHandler(NetworkParameters params, PeerAddress peerAddress) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = checkNotNull(peerAddress); }
public PeerSocketHandler(NetworkParameters params, PeerAddress peerAddress) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = checkNotNull(peerAddress); }
public PeerSocketHandler(NetworkParameters params, PeerAddress peerAddress) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = checkNotNull(peerAddress); }
public PeerSocketHandler(NetworkParameters params, InetSocketAddress remoteIp) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = new PeerAddress(params, remoteIp); }
public PeerSocketHandler(NetworkParameters params, InetSocketAddress remoteIp) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = new PeerAddress(params, remoteIp); }
public PeerSocketHandler(NetworkParameters params, InetSocketAddress remoteIp) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = new PeerAddress(params, remoteIp); }
public PeerSocketHandler(NetworkParameters params, InetSocketAddress remoteIp) { checkNotNull(params); serializer = params.getDefaultSerializer(); this.peerAddress = new PeerAddress(params, remoteIp); }
/** De-serializes the stored block from a custom packed format. Used by {@link CheckpointManager}. */ public static StoredBlock deserializeCompact(NetworkParameters params, ByteBuffer buffer) throws ProtocolException { byte[] chainWorkBytes = new byte[StoredBlock.CHAIN_WORK_BYTES]; buffer.get(chainWorkBytes); BigInteger chainWork = new BigInteger(1, chainWorkBytes); int height = buffer.getInt(); // +4 bytes byte[] header = new byte[Block.HEADER_SIZE + 1]; // Extra byte for the 00 transactions length. buffer.get(header, 0, Block.HEADER_SIZE); return new StoredBlock(params.getDefaultSerializer().makeBlock(header), chainWork, height); }
/** De-serializes the stored block from a custom packed format. Used by {@link CheckpointManager}. */ public static StoredBlock deserializeCompact(NetworkParameters params, ByteBuffer buffer) throws ProtocolException { byte[] chainWorkBytes = new byte[StoredBlock.CHAIN_WORK_BYTES]; buffer.get(chainWorkBytes); BigInteger chainWork = new BigInteger(1, chainWorkBytes); int height = buffer.getInt(); // +4 bytes byte[] header = new byte[Block.HEADER_SIZE + 1]; // Extra byte for the 00 transactions length. buffer.get(header, 0, Block.HEADER_SIZE); return new StoredBlock(params.getDefaultSerializer().makeBlock(header), chainWork, height); }
@Override protected void parse() throws ProtocolException { byte[] headerBytes = new byte[Block.HEADER_SIZE]; System.arraycopy(payload, 0, headerBytes, 0, Block.HEADER_SIZE); header = params.getDefaultSerializer().makeBlock(headerBytes); merkleTree = new PartialMerkleTree(params, payload, Block.HEADER_SIZE); length = Block.HEADER_SIZE + merkleTree.getMessageSize(); }
@Override protected void parse() throws ProtocolException { byte[] headerBytes = new byte[Block.HEADER_SIZE]; System.arraycopy(payload, 0, headerBytes, 0, Block.HEADER_SIZE); header = params.getDefaultSerializer().makeBlock(headerBytes); merkleTree = new PartialMerkleTree(params, payload, Block.HEADER_SIZE); length = Block.HEADER_SIZE + merkleTree.getMessageSize(); }
@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); }
@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())); }