public void WriteTo(Stream output) { var proto = new ProtobufReaderWriter(output); if (MerchantData != null) { proto.WriteKey(1, ProtobufReaderWriter.PROTOBUF_LENDELIM); proto.WriteBytes(MerchantData); } foreach (var tx in Transactions) { proto.WriteKey(2, ProtobufReaderWriter.PROTOBUF_LENDELIM); proto.WriteBytes(tx.ToBytes()); } foreach (var txout in RefundTo) { proto.WriteKey(3, ProtobufReaderWriter.PROTOBUF_LENDELIM); proto.WriteBytes(txout.ToBytes()); } if (Memo != null) { proto.WriteKey(4, ProtobufReaderWriter.PROTOBUF_LENDELIM); proto.WriteString(Memo); } }
void WriteTo(ProtobufReaderWriter writer) { if (_DetailsVersion != null) { writer.WriteKey(1, ProtobufReaderWriter.PROTOBUF_VARINT); writer.WriteULong((uint)_DetailsVersion); } writer.WriteKey(2, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteString(ToPKITypeString(PKIType)); writer.WriteKey(3, ProtobufReaderWriter.PROTOBUF_LENDELIM); MemoryStream ms = new MemoryStream(); ProtobufReaderWriter certs = new ProtobufReaderWriter(ms); if (this.MerchantCertificate != null) { certs.WriteKey(1, ProtobufReaderWriter.PROTOBUF_LENDELIM); certs.WriteBytes(MerchantCertificate); } foreach (var cert in AdditionalCertificates) { certs.WriteKey(1, ProtobufReaderWriter.PROTOBUF_LENDELIM); certs.WriteBytes(cert); } writer.WriteBytes(ms.ToArrayEfficient()); writer.WriteKey(4, ProtobufReaderWriter.PROTOBUF_LENDELIM); ms = new MemoryStream(); Details.WriteTo(ms); writer.WriteBytes(ms.ToArray()); writer.WriteKey(5, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteBytes(Signature ?? new byte[0]); }
public void WriteTo(Stream stream) { var writer = new ProtobufReaderWriter(stream); if (_Network != null) { var str = _Network == Network.Main ? "main" : _Network == Network.TestNet ? "test" : _Network == Network.RegTest ? "regtest" : null; if (str == null) { throw new InvalidOperationException("Impossible to serialize a payment request on network " + _Network); } writer.WriteKey(1, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteString(str); } foreach (var txout in Outputs) { writer.WriteKey(2, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteBytes(txout.ToBytes()); } writer.WriteKey(3, ProtobufReaderWriter.PROTOBUF_VARINT); writer.WriteULong(Utils.DateTimeToUnixTime(Time)); if (Expires != null) { writer.WriteKey(4, ProtobufReaderWriter.PROTOBUF_VARINT); writer.WriteULong(Utils.DateTimeToUnixTime(Expires.Value)); } if (Memo != null) { writer.WriteKey(5, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteString(Memo); } if (PaymentUrl != null) { writer.WriteKey(6, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteString(PaymentUrl.AbsoluteUri); } if (MerchantData != null) { writer.WriteKey(7, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteBytes(MerchantData); } }
public void WriteTo(Stream output) { Protobuf.ProtobufReaderWriter proto = new ProtobufReaderWriter(output); proto.WriteKey(1, ProtobufReaderWriter.PROTOBUF_LENDELIM); proto.WriteBytes(Payment.ToBytes()); if (Memo != null) { proto.WriteKey(2, ProtobufReaderWriter.PROTOBUF_LENDELIM); proto.WriteString(Memo); } }
internal void Write(Stream output) { var writer = new ProtobufReaderWriter(output); if (_Amount != null) { writer.WriteKey(1, ProtobufReaderWriter.PROTOBUF_VARINT); writer.WriteULong((ulong)_Amount.Satoshi); } writer.WriteKey(2, ProtobufReaderWriter.PROTOBUF_LENDELIM); writer.WriteBytes(Script == null ? new byte[0] : Script.ToBytes(true)); }