public void ReadWrite(BitcoinStream stream) { using (stream.BigEndianScope()) { stream.ReadWrite(ref this.nDepth); stream.ReadWrite(ref this.vchFingerprint); stream.ReadWrite(ref this.nChild); stream.ReadWrite(ref this.vchChainCode); stream.ReadWrite(ref this.pubkey); } }
public void ReadWrite(BitcoinStream stream) { if (stream.ProtocolVersion >= ProtocolVersion.CADDR_TIME_VERSION) { stream.ReadWrite(ref time); } stream.ReadWrite(ref service); stream.ReadWrite(ref ip); using (stream.BigEndianScope()) { stream.ReadWrite(ref port); } }
public void ReadWrite(BitcoinStream stream) { using (stream.BigEndianScope()) { stream.ReadWrite(ref nDepth); stream.ReadWrite(ref vchFingerprint); stream.ReadWrite(ref nChild); stream.ReadWrite(ref vchChainCode); byte b = 0; stream.ReadWrite(ref b); stream.ReadWrite(ref key); } }
private static byte[] ToCommitment(Money amount) { if (amount == null) { return(null); } var ms = new MemoryStream(); var stream = new BitcoinStream(ms, true); ms.WriteByte(1); stream.BigEndianScope(); long m = amount.Satoshi; stream.ReadWrite(ref m); return(ms.ToArrayEfficient()); }
public void ReadWrite(BitcoinStream stream) { if (stream.Type == SerializationType.Disk) { stream.ReadWrite(ref version); } if ( stream.Type == SerializationType.Disk || (stream.ProtocolCapabilities.SupportTimeAddress && stream.Type != SerializationType.Hash)) { stream.ReadWrite(ref ntime); } stream.ReadWrite(ref service); stream.ReadWrite(ref ip); using (stream.BigEndianScope()) { stream.ReadWrite(ref port); } }
public void ReadWrite(BitcoinStream stream) { if (stream.Type == SerializationType.Disk) { stream.ReadWrite(ref this.version); } if ((stream.Type == SerializationType.Disk) || ((stream.ProtocolVersion >= ProtocolVersion.CADDR_TIME_VERSION) && (stream.Type != SerializationType.Hash))) { stream.ReadWrite(ref this.ntime); } stream.ReadWrite(ref this.service); stream.ReadWrite(ref this.ip); using (stream.BigEndianScope()) { stream.ReadWrite(ref this.port); } }
public void ReadWrite(BitcoinStream stream) { using(stream.BigEndianScope()) { stream.ReadWrite(ref nDepth); stream.ReadWrite(ref vchFingerprint); stream.ReadWrite(ref nChild); stream.ReadWrite(ref vchChainCode); byte b = 0; stream.ReadWrite(ref b); stream.ReadWrite(ref key); } }
public virtual void ReadWrite(BitcoinStream stream) { var version = stream.ProtocolVersion ?? 0; if (stream.Type == SerializationType.Disk) { stream.ReadWrite(ref version); } if ( stream.Type == SerializationType.Disk || (stream.ProtocolCapabilities.SupportTimeAddress && stream.Type != SerializationType.Hash)) { // The only time we serialize a CAddress object without nTime is in // the initial VERSION messages which contain two CAddress records. // At that point, the serialization version is INIT_PROTO_VERSION. // After the version handshake, serialization version is >= // MIN_PEER_PROTO_VERSION and all ADDR messages are serialized with // nTime. stream.ReadWrite(ref nTime); } if ((version & AddrV2Format) != 0) { stream.ReadWriteAsVarInt(ref services); } else { stream.ReadWrite(ref services); } var useV2Format = stream.ProtocolVersion is {} protcocolVersion&& (protcocolVersion & AddrV2Format) != 0; if (useV2Format) { if (stream.Serializing) { var bip155net = (byte)GetBIP155Network(); stream.ReadWrite(bip155net); stream.ReadWriteAsVarString(ref addr); } else { byte n = 0; stream.ReadWrite(ref n); stream.ReadWriteAsVarString(ref addr); if (SetNetFromBIP155Network((BIP155Network)n, addr.Length)) { if (network == NetworkAddressType.IPv6) { if (HasPrefix(addr, IPV4_IN_IPV6_PREFIX) || HasPrefix(addr, TORV2_IN_IPV6_PREFIX)) { // set to invalid because IPv4 and Torv2 should not be embeded in IPv6. addr = IPV6_NONE; network = NetworkAddressType.IPv6; } } } else { // set to invalid because IPv4 and Torv2 should not be embeded in IPv6. addr = IPV6_NONE; network = NetworkAddressType.IPv6; } } } else { if (stream.Serializing) { var localAddr = IsAddrV1Compatible ? SerializeV1Array() : IPV6_NONE; stream.ReadWrite(ref localAddr); } else { var localAddr = new byte[ADDR_IPV6_SIZE]; stream.ReadWrite(ref localAddr); SetLegacyIpv6(localAddr); } } using (stream.BigEndianScope()) { stream.ReadWrite(ref port); } }
public void ReadWrite(BitcoinStream stream) { if(stream.ProtocolVersion >= ProtocolVersion.CADDR_TIME_VERSION) stream.ReadWrite(ref time); stream.ReadWrite(ref service); stream.ReadWrite(ref ip); using(stream.BigEndianScope()) { stream.ReadWrite(ref port); } }
public void ReadWrite(BitcoinStream stream) { if(stream.Type == SerializationType.Disk) { stream.ReadWrite(ref version); } if( stream.Type == SerializationType.Disk || (stream.ProtocolVersion >= ProtocolVersion.CADDR_TIME_VERSION && stream.Type != SerializationType.Hash)) stream.ReadWrite(ref ntime); stream.ReadWrite(ref service); stream.ReadWrite(ref ip); using(stream.BigEndianScope()) { stream.ReadWrite(ref port); } }