@Override protected void bitcoinSerializeToStream(OutputStream stream) throws IOException { if (addresses == null) return; stream.write(new VarInt(addresses.size()).encode()); for (PeerAddress addr : addresses) { addr.bitcoinSerialize(stream); } }
@Override protected void bitcoinSerializeToStream(OutputStream stream) throws IOException { if (addresses == null) return; stream.write(new VarInt(addresses.size()).encode()); for (PeerAddress addr : addresses) { addr.bitcoinSerialize(stream); } }
@Override protected void bitcoinSerializeToStream(OutputStream stream) throws IOException { if (addresses == null) return; stream.write(new VarInt(addresses.size()).encode()); for (PeerAddress addr : addresses) { addr.bitcoinSerialize(stream); } }
@Override protected void bitcoinSerializeToStream(OutputStream stream) throws IOException { if (addresses == null) return; stream.write(new VarInt(addresses.size()).encode()); for (PeerAddress addr : addresses) { addr.bitcoinSerialize(stream); } }
@Override public void bitcoinSerializeToStream(OutputStream buf) throws IOException { Utils.uint32ToByteStreamLE(clientVersion, buf); Utils.uint32ToByteStreamLE(localServices, buf); Utils.uint32ToByteStreamLE(localServices >> 32, buf); Utils.uint32ToByteStreamLE(time, buf); Utils.uint32ToByteStreamLE(time >> 32, buf); try { // My address. myAddr.bitcoinSerialize(buf); // Their address. theirAddr.bitcoinSerialize(buf); } catch (UnknownHostException e) { throw new RuntimeException(e); // Can't happen. } catch (IOException e) { throw new RuntimeException(e); // Can't happen. } // Next up is the "local host nonce", this is to detect the case of connecting // back to yourself. We don't care about this as we won't be accepting inbound // connections. Utils.uint32ToByteStreamLE(0, buf); Utils.uint32ToByteStreamLE(0, buf); // Now comes subVer. byte[] subVerBytes = subVer.getBytes("UTF-8"); buf.write(new VarInt(subVerBytes.length).encode()); buf.write(subVerBytes); // Size of known block chain. Utils.uint32ToByteStreamLE(bestHeight, buf); buf.write(relayTxesBeforeFilter ? 1 : 0); }
@Override public void bitcoinSerializeToStream(OutputStream buf) throws IOException { Utils.uint32ToByteStreamLE(clientVersion, buf); Utils.uint32ToByteStreamLE(localServices, buf); Utils.uint32ToByteStreamLE(localServices >> 32, buf); Utils.uint32ToByteStreamLE(time, buf); Utils.uint32ToByteStreamLE(time >> 32, buf); try { // My address. myAddr.bitcoinSerialize(buf); // Their address. theirAddr.bitcoinSerialize(buf); } catch (UnknownHostException e) { throw new RuntimeException(e); // Can't happen. } catch (IOException e) { throw new RuntimeException(e); // Can't happen. } // Next up is the "local host nonce", this is to detect the case of connecting // back to yourself. We don't care about this as we won't be accepting inbound // connections. Utils.uint32ToByteStreamLE(0, buf); Utils.uint32ToByteStreamLE(0, buf); // Now comes subVer. byte[] subVerBytes = subVer.getBytes("UTF-8"); buf.write(new VarInt(subVerBytes.length).encode()); buf.write(subVerBytes); // Size of known block chain. Utils.uint32ToByteStreamLE(bestHeight, buf); buf.write(relayTxesBeforeFilter ? 1 : 0); }
@Override public void bitcoinSerializeToStream(OutputStream buf) throws IOException { Utils.uint32ToByteStreamLE(clientVersion, buf); Utils.uint32ToByteStreamLE(localServices, buf); Utils.uint32ToByteStreamLE(localServices >> 32, buf); Utils.uint32ToByteStreamLE(time, buf); Utils.uint32ToByteStreamLE(time >> 32, buf); try { // My address. myAddr.bitcoinSerialize(buf); // Their address. theirAddr.bitcoinSerialize(buf); } catch (UnknownHostException e) { throw new RuntimeException(e); // Can't happen. } catch (IOException e) { throw new RuntimeException(e); // Can't happen. } // Next up is the "local host nonce", this is to detect the case of connecting // back to yourself. We don't care about this as we won't be accepting inbound // connections. Utils.uint32ToByteStreamLE(0, buf); Utils.uint32ToByteStreamLE(0, buf); // Now comes subVer. byte[] subVerBytes = subVer.getBytes("UTF-8"); buf.write(new VarInt(subVerBytes.length).encode()); buf.write(subVerBytes); // Size of known block chain. Utils.uint32ToByteStreamLE(bestHeight, buf); buf.write(relayTxesBeforeFilter ? 1 : 0); }
@Override public void bitcoinSerializeToStream(OutputStream buf) throws IOException { Utils.uint32ToByteStreamLE(clientVersion, buf); Utils.uint32ToByteStreamLE(localServices, buf); Utils.uint32ToByteStreamLE(localServices >> 32, buf); Utils.uint32ToByteStreamLE(time, buf); Utils.uint32ToByteStreamLE(time >> 32, buf); try { // My address. myAddr.bitcoinSerialize(buf); // Their address. theirAddr.bitcoinSerialize(buf); } catch (UnknownHostException e) { throw new RuntimeException(e); // Can't happen. } catch (IOException e) { throw new RuntimeException(e); // Can't happen. } // Next up is the "local host nonce", this is to detect the case of connecting // back to yourself. We don't care about this as we won't be accepting inbound // connections. Utils.uint32ToByteStreamLE(0, buf); Utils.uint32ToByteStreamLE(0, buf); // Now comes subVer. byte[] subVerBytes = subVer.getBytes("UTF-8"); buf.write(new VarInt(subVerBytes.length).encode()); buf.write(subVerBytes); // Size of known block chain. Utils.uint32ToByteStreamLE(bestHeight, buf); buf.write(relayTxesBeforeFilter ? 1 : 0); }
@Test public void testBitcoinSerialize() throws Exception { PeerAddress pa = new PeerAddress(MainNetParams.get(), InetAddress.getByName(null), 8333, 0, BigInteger.ZERO); assertEquals("000000000000000000000000000000000000ffff7f000001208d", Utils.HEX.encode(pa.bitcoinSerialize())); } }