/// <exception cref="System.IO.IOException" /> public override void BitcoinSerializeToStream(Stream buf) { Utils.Uint32ToByteStreamLe(ClientVersion, buf); Utils.Uint64ToByteStreamLe(LocalServices, buf); Utils.Uint64ToByteStreamLe(Time, buf); // My address. MyAddr.BitcoinSerializeToStream(buf); // Their address. TheirAddr.BitcoinSerializeToStream(buf); // 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.Uint64ToByteStreamLe(_localHostNonce, buf); // Now comes subVer. var subVerBytes = Encoding.UTF8.GetBytes(SubVer); buf.Write(new VarInt((ulong)subVerBytes.Length).Encode()); buf.Write(subVerBytes); // Size of known block chain. Utils.Uint32ToByteStreamLe(BestHeight, buf); }
/// <exception cref="IOException"/> public override void BitcoinSerializeToStream(Stream buf) { Utilities.Uint32ToByteStreamLe(ClientVersion, buf); Utilities.Uint64ToByteStreamLe(LocalServices, buf); Utilities.Uint64ToByteStreamLe(Time, buf); // Their address. TheirAddr.BitcoinSerializeToStream(buf); // My address. MyAddr.BitcoinSerializeToStream(buf); // 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. Utilities.Uint64ToByteStreamLe(_nonce, buf); // Now comes subVer. var subVerBytes = Encoding.UTF8.GetBytes(_userAgent); //this was f*****g me.....I'm like what even but seeing the message in wireshark switched me on to the fact we need size byte of string before string buf.WriteByte(Convert.ToByte(subVerBytes.Length)); buf.Write(subVerBytes, 0, subVerBytes.Length); // Size of known block chain. Utilities.Uint32ToByteStreamLe(_startBlockHeight, buf); buf.WriteByte((byte)_relay); }