public static string EncodeCheck(VersionByte versionByte, byte[] data) { var writer = new ByteWriter(); writer.Write((byte)versionByte); writer.Write(data); byte[] checksum = StrKey.CalculateChecksum(writer.ToArray()); writer.Write(checksum); return Base32Encoding.ToString(writer.ToArray()); }
public static string EncodeCheck(VersionByte versionByte, byte[] data) { var writer = new Generated.ByteWriter(); writer.Write((byte)versionByte); writer.Write(data); byte[] checksum = StrKey.CalculateChecksum(writer.ToArray()); writer.Write(checksum); return(Base32Encoding.ToString(writer.ToArray())); }
/// <summary> /// Returns base64-encoded Operation XDR object. /// </summary> /// <returns></returns> public string ToXdrBase64() { var operation = ToXdr(); var writer = new Generated.ByteWriter(); Generated.Operation.Encode(writer, operation); return Convert.ToBase64String(writer.ToArray()); }
/// <summary> /// Returns base64-encoded TransactionEnvelope XDR object. Transaction need to have at least one signature. /// </summary> /// <returns></returns> public string ToEnvelopeXdrBase64() { var envelope = ToEnvelopeXDR(); var writer = new Generated.ByteWriter(); Generated.TransactionEnvelope.Encode(writer, envelope); return(Convert.ToBase64String(writer.ToArray())); }
/// <summary> /// Returns base64-encoded Operation XDR object. /// </summary> /// <returns></returns> public string ToXdrBase64() { var operation = ToXdr(); var writer = new Generated.ByteWriter(); Generated.Operation.Encode(writer, operation); return(Convert.ToBase64String(writer.ToArray())); }
public void SignatureBaseTest() { var transaction = SampleTransaction("GDICFS3KJ3ZTW4COVPUX7OCOAZKLLNFAM5FIYSN5FKKM7M7QNXLBPCCH"); var txXdr = transaction.ToXdr(); var writer = new Stellar.Generated.ByteWriter(); Stellar.Generated.Transaction.Encode(writer, txXdr); string sig64 = Convert.ToBase64String(writer.ToArray()); string sigSample64 = "AAAAAL6Qe0ushP7lzogR2y3vyb8LKiorvD1U2KIlfs1wRBliAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAA0CLLak7zO3BOq+l/uE4GVLW0oGdKjEm9KpTPs/Bt1hcAAAAAAAAD6AAAAAA="; byte[] sigSample = Convert.FromBase64String(sigSample64); var reader = new Stellar.Generated.ByteReader(sigSample); var sampleTx = Stellar.Generated.Transaction.Decode(reader); CollectionAssert.AreEqual(writer.ToArray(), sigSample); Assert.AreEqual(sigSample64, sig64); }
public void SignatureBaseTest() { var transaction = SampleTransaction("GDICFS3KJ3ZTW4COVPUX7OCOAZKLLNFAM5FIYSN5FKKM7M7QNXLBPCCH"); var txXdr = transaction.ToXDR(); var writer = new Stellar.Generated.ByteWriter(); Stellar.Generated.Transaction.Encode(writer, txXdr); string sig64 = Convert.ToBase64String(writer.ToArray()); string sigSample64 = "AAAAAL6Qe0ushP7lzogR2y3vyb8LKiorvD1U2KIlfs1wRBliAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAA0CLLak7zO3BOq+l/uE4GVLW0oGdKjEm9KpTPs/Bt1hcAAAAAAAAD6AAAAAA="; byte[] sigSample = Convert.FromBase64String(sigSample64); var reader = new Stellar.Generated.ByteReader(sigSample); var sampleTx = Stellar.Generated.Transaction.Decode(reader); CollectionAssert.AreEqual(writer.ToArray(), sigSample); Assert.AreEqual(sigSample64, sig64); }
/// <summary> /// Returns signature base. /// </summary> /// <returns></returns> public byte[] SignatureBase() { var writer = new Generated.ByteWriter(); // Hashed NetworkID writer.Write(Network.CurrentNetworkId); // Envelope Type - 4 bytes Generated.EnvelopeType.Encode(writer, Generated.EnvelopeType.Create(Generated.EnvelopeType.EnvelopeTypeEnum.ENVELOPE_TYPE_TX)); // Transaction XDR bytes var txWriter = new Generated.ByteWriter(); Generated.Transaction.Encode(txWriter, this.ToXdr()); writer.Write(txWriter.ToArray()); return writer.ToArray(); }
/// <summary> /// Returns signature base. /// </summary> /// <returns></returns> public byte[] SignatureBase() { var writer = new Generated.ByteWriter(); // Hashed NetworkID writer.Write(Network.CurrentNetworkId); // Envelope Type - 4 bytes Generated.EnvelopeType.Encode(writer, Generated.EnvelopeType.Create(Generated.EnvelopeType.EnvelopeTypeEnum.ENVELOPE_TYPE_TX)); // Transaction XDR bytes var txWriter = new Generated.ByteWriter(); Generated.Transaction.Encode(txWriter, this.ToXDR()); writer.Write(txWriter.ToArray()); return(writer.ToArray()); }
/// <summary> /// Returns base64-encoded TransactionEnvelope XDR object. Transaction need to have at least one signature. /// </summary> /// <returns></returns> public string ToEnvelopeXdrBase64() { var envelope = ToEnvelopeXdr(); var writer = new Generated.ByteWriter(); Generated.TransactionEnvelope.Encode(writer, envelope); return Convert.ToBase64String(writer.ToArray()); }