コード例 #1
0
        public void TestDecodeTxNoTail()
        {
            var noTailTransactionXdr =
                "AAAAAEntn0+aXWXUuLtq9RDTOQHw6FKCz4YULdFpx6KrFLM2AAABLACOUUAAAAAEAAAAAQAAAABbFYjQAAAAAH////8AAAABAAAAFEVDTFlQU0VTQ09JTiBQYXltZW50AAAAAwAAAAAAAAABAAAAANqNgkK/Piz99iwrbp+Lr2LjwDKul8tgETQO2igoZaaNAAAAAkVDTFlQU0VTQ09JTgAAAABwYz2lcMDGOi6MU/sYdRuBye2KWD5aolXM/Yxdr8X9+AAAAAAF9eEAAAAAAAAAAAYAAAACRUNMWVBTRVNDT0lOAAAAAHBjPaVwwMY6LoxT+xh1G4HJ7YpYPlqiVcz9jF2vxf34AAAAAAAAAAAAAAABAAAAAEntn0+aXWXUuLtq9RDTOQHw6FKCz4YULdFpx6KrFLM2AAAACAAAAACxJkMYYoztLLzXom8YBWAqFrREfEt3DvmQepBBLNCzbQAAAAAAAAABLNCzbQAAAEDjlco8Cz8GnuFItJVUUEMPYizwC5LLTxueNI9KEf1fgyPZ0hYC5IQP5Augl/p78z5WpnHfFZXYz3vXMf6buhgN";

            var bytes = noTailTransactionXdr.ToCharArray();
            var xdrDataInputStream = new XdrDataInputStream(Convert.FromBase64CharArray(bytes, 0, bytes.Length));

            var decodedTransaction = Transaction.Decode(xdrDataInputStream);
            var memo = decodedTransaction.Memo.Text;

            Assert.AreEqual("ECLYPSESCOIN Payment", memo);
        }
コード例 #2
0
        public static TransactionV1Envelope Decode(XdrDataInputStream stream)
        {
            TransactionV1Envelope decodedTransactionV1Envelope = new TransactionV1Envelope();

            decodedTransactionV1Envelope.Tx = Transaction.Decode(stream);
            int signaturessize = stream.ReadInt();

            decodedTransactionV1Envelope.Signatures = new DecoratedSignature[signaturessize];
            for (int i = 0; i < signaturessize; i++)
            {
                decodedTransactionV1Envelope.Signatures[i] = DecoratedSignature.Decode(stream);
            }
            return(decodedTransactionV1Envelope);
        }
コード例 #3
0
            public static TransactionSignaturePayloadTaggedTransaction Decode(XdrDataInputStream stream)
            {
                TransactionSignaturePayloadTaggedTransaction decodedTransactionSignaturePayloadTaggedTransaction = new TransactionSignaturePayloadTaggedTransaction();
                EnvelopeType discriminant = EnvelopeType.Decode(stream);

                decodedTransactionSignaturePayloadTaggedTransaction.Discriminant = discriminant;
                switch (decodedTransactionSignaturePayloadTaggedTransaction.Discriminant.InnerValue)
                {
                case EnvelopeType.EnvelopeTypeEnum.ENVELOPE_TYPE_TX:
                    decodedTransactionSignaturePayloadTaggedTransaction.Tx = Transaction.Decode(stream);
                    break;
                }
                return(decodedTransactionSignaturePayloadTaggedTransaction);
            }
コード例 #4
0
        public void TestBuilderTimeBounds()
        {
            // GBPMKIRA2OQW2XZZQUCQILI5TMVZ6JNRKM423BSAISDM7ZFWQ6KWEBC4
            var source      = KeyPair.FromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
            var destination = KeyPair.FromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR");

            var account     = new Account(source, 2908908335136768L);
            var transaction = new Transaction.Builder(account)
                              .AddOperation(new CreateAccountOperation.Builder(destination, "2000").Build())
                              .AddTimeBounds(new TimeBounds(42, 1337))
                              .Build();

            transaction.Sign(source);

            // Convert transaction to binary XDR and back again to make sure timebounds are correctly de/serialized.
            var bytes = transaction.ToEnvelopeXdrBase64().ToCharArray();
            var xdrDataInputStream = new XdrDataInputStream(Convert.FromBase64CharArray(bytes, 0, bytes.Length));

            var decodedTransaction = XdrTransaction.Decode(xdrDataInputStream);

            Assert.AreEqual(decodedTransaction.TimeBounds.MinTime.InnerValue, 42);
            Assert.AreEqual(decodedTransaction.TimeBounds.MaxTime.InnerValue, 1337);
        }
コード例 #5
0
        public void TestBuilderFee()
        {
            // GBPMKIRA2OQW2XZZQUCQILI5TMVZ6JNRKM423BSAISDM7ZFWQ6KWEBC4
            var source      = KeyPair.FromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
            var destination = KeyPair.FromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR");

            var account     = new Account(source.AccountId, 2908908335136768L);
            var transaction = new TransactionBuilder(account)
                              .AddOperation(new CreateAccountOperation.Builder(destination, "2000").Build())
                              .AddOperation(new CreateAccountOperation.Builder(destination, "2000").Build())
                              .SetFee(173)
                              .Build();

            // Convert transaction to binary XDR and back again to make sure fee is correctly de/serialized.
            var bytes = transaction.ToUnsignedEnvelopeXdrBase64().ToCharArray();
            var xdrDataInputStream = new XdrDataInputStream(Convert.FromBase64CharArray(bytes, 0, bytes.Length));

            var decodedTransaction = XdrTransaction.Decode(xdrDataInputStream);

            Assert.AreEqual(decodedTransaction.Fee.InnerValue, 173 * 2U);

            var transaction2 = Transaction.FromEnvelopeXdr(transaction.ToUnsignedEnvelopeXdr());

            Assert.AreEqual(transaction.SourceAccount.AccountId, transaction2.SourceAccount.AccountId);
            Assert.AreEqual(transaction.SequenceNumber, transaction2.SequenceNumber);
            Assert.AreEqual(transaction.Memo, transaction2.Memo);
            Assert.AreEqual(transaction.TimeBounds, transaction2.TimeBounds);
            Assert.AreEqual(transaction.Fee, transaction2.Fee);
            Assert.AreEqual(
                ((CreateAccountOperation)transaction.Operations[0]).StartingBalance,
                ((CreateAccountOperation)transaction2.Operations[0]).StartingBalance
                );
            Assert.AreEqual(
                ((CreateAccountOperation)transaction.Operations[1]).StartingBalance,
                ((CreateAccountOperation)transaction2.Operations[1]).StartingBalance
                );
        }