コード例 #1
0
        public async void MultisigTransaction_Clicked(System.Object sender, System.EventArgs e)
        {
            //MultisigTransaction

            // List for Pks for multisig account
            List <Ed25519PublicKeyParameters> publicKeys = new List <Ed25519PublicKeyParameters>();

            // restore accounts
            var accounts = await helper.RestoreAccounts();

            Account account1 = accounts[0];
            Account account2 = accounts[1];
            Account account3 = accounts[2];


            publicKeys.Add(account1.GetEd25519PublicKey());
            publicKeys.Add(account2.GetEd25519PublicKey());
            publicKeys.Add(account3.GetEd25519PublicKey());

            // Instantiate the the Multisig Accout

            MultisigAddress msig = new MultisigAddress(1, 2, publicKeys);

            Console.WriteLine("Multisignature Address: " + msig.ToString());
            //   dispense funds to msig account
            string DEST_ADDR = account3.Address.ToString();

            // add some notes to the transaction

            // todo notes
            byte[] notes = Encoding.UTF8.GetBytes("These are some notes encoded in some way!");//.getBytes();

            var         amount = Utils.AlgosToMicroalgos(1);
            Transaction tx     = null;

            //noteb64 = notes
            try
            {
                tx = Utils.GetPaymentTransaction(new Address(msig.ToString()), new Address(DEST_ADDR), amount, "this is a multisig trans",
                                                 algodApiInstance.TransactionParams());
            }
            catch (Exception err)
            {
                Console.WriteLine("Could not get params", err.Message);
            }
            // Sign the Transaction for two accounts
            SignedTransaction signedTx   = account1.SignMultisigTransaction(msig, tx);
            SignedTransaction completeTx = account2.AppendMultisigTransaction(msig, signedTx);

            // send the transaction to the network
            PostTransactionsResponse id = null;

            try
            {
                id = Utils.SubmitTransaction(algodApiInstance, completeTx);
                Console.WriteLine("Successfully sent tx with id: " + id.TxId);
                var x = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId);
                Console.WriteLine(x);
            }
            catch (ApiException err)
            {
                Console.WriteLine("Exception when calling algod#rawTransaction: " + err.Message);
            }
            await SecureStorage.SetAsync(helper.StorageMultisigTransaction, id.TxId.ToString());

            MultisigTransaction.Text = "Transaction successfully sent";
            GetMultiSigTx.IsVisible  = true;

            MultisigTransactionp.Text = "Transaction successfully sent";
            GetMultiSigTxp.IsVisible  = true;

            //ulong? balance = await helper.GetAccountBalance(helper.StorageMultisig);
            //var htmlSource = new HtmlWebViewSource();
            //htmlSource.Html = @"<html><body><h3> Multisig balance = " + balance.ToString() + " </h3>" +
            //      "</body></html>";

            //myWebView.Source = htmlSource;



            buttonstate();

            await DisplayAccount(helper.StorageAccountName3);

            //var mytx = await SecureStorage.GetAsync(helper.StorageMultisigTransaction);

            //if (!(mytx == null || mytx == ""))

            //{
            //    htmlSource = new HtmlWebViewSource();
            //    htmlSource.Html = @"<html><body><h3> Transaction ID = " + mytx.ToString() + " </h3>" +
            //          "</body></html>";

            //    myWebView.Source = htmlSource;


            //}
        }