Пример #1
0
        public void TestSetOptionsOperationPreAuthTxSigner()
        {
            Network.UseTestNetwork();

            // GBPMKIRA2OQW2XZZQUCQILI5TMVZ6JNRKM423BSAISDM7ZFWQ6KWEBC4
            var source      = KeyPair.FromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
            var destination = KeyPair.FromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR");

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

            // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
            var opSource = KeyPair.FromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");

            var operation = new SetOptionsOperation.Builder()
                            .SetSigner(Signer.PreAuthTx(transaction), 10)
                            .SetSourceAccount(opSource)
                            .Build();

            var xdr             = operation.ToXdr();
            var parsedOperation = (SetOptionsOperation)Operation.FromXdr(xdr);

            Assert.AreEqual(null, parsedOperation.InflationDestination);
            Assert.AreEqual(null, parsedOperation.ClearFlags);
            Assert.AreEqual(null, parsedOperation.SetFlags);
            Assert.AreEqual(null, parsedOperation.MasterKeyWeight);
            Assert.AreEqual(null, parsedOperation.LowThreshold);
            Assert.AreEqual(null, parsedOperation.MediumThreshold);
            Assert.AreEqual(null, parsedOperation.HighThreshold);
            Assert.AreEqual(null, parsedOperation.HomeDomain);
            Assert.IsTrue(transaction.Hash().SequenceEqual(parsedOperation.Signer.PreAuthTx.InnerValue));
            Assert.AreEqual(10, parsedOperation.SignerWeight);
            Assert.AreEqual(opSource.AccountId, parsedOperation.SourceAccount.AccountId);

            Assert.AreEqual(
                "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAB1vRBIRC3w7ZH5rQa17hIBKUwZTvBP4kNmSP7jVyw1fQAAAAK",
                operation.ToXdrBase64());
        }