public void testAppendMultisigKeyRegTransaction() { MultisigAddress addr = makeTestMsigAddr(); byte[] firstTxBytes = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAujReoxR7FeTUTqgOn+rS20XOF3ENA+JrSgZ5yvrDPg3NQAzQzUXddB0PVvPRn490oVSQaHEIY05EDJXVBFPJD4GicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxgaJwa8Qg5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKGjdGhyAqF2AaN0eG6Jo2ZlZc4AA8jAomZ2zgAO+dqibHbOAA79wqZzZWxrZXnEIDISKyvWPdxTMZYXpapTxLHCb+PcyvKNNiK1aXehQFyGo3NuZMQgjZK0iZABc6BN+kNZo2ZqavzqLEKgXdnB9z7rpUeAN+mkdHlwZaZrZXlyZWemdm90ZWtkzScQp3ZvdGVrZXnEIHAb1/uRKwezCBH/KB2f7pVj5YAuICaJIxklj3f6kx6Ip3ZvdGVsc3TOAA9CQA=="); byte[] seed = Mnemonic.ToKey("advice pudding treat near rule blouse same whisper inner electric quit surface sunny dismiss leader blood seat clown cost exist hospital century reform able sponsor"); Account account = new Account(seed); byte[] appended = account.AppendMultisigTransactionBytes(addr, firstTxBytes); byte[] expected = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAujReoxR7FeTUTqgOn+rS20XOF3ENA+JrSgZ5yvrDPg3NQAzQzUXddB0PVvPRn490oVSQaHEIY05EDJXVBFPJD4GicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxgqJwa8Qg5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKGhc8RArIVZWayeobzKSv+zpJJmbrjsglY5J09/1KU37T5cSl595mMotqO7a2Hmz0XaRxoS6pVhsc2YSkMiU/YhHJCcA6N0aHICoXYBo3R4bomjZmVlzgADyMCiZnbOAA752qJsds4ADv3CpnNlbGtlecQgMhIrK9Y93FMxlhelqlPEscJv49zK8o02IrVpd6FAXIajc25kxCCNkrSJkAFzoE36Q1mjZmpq/OosQqBd2cH3PuulR4A36aR0eXBlpmtleXJlZ6Z2b3Rla2TNJxCndm90ZWtlecQgcBvX+5ErB7MIEf8oHZ/ulWPlgC4gJokjGSWPd/qTHoindm90ZWxzdM4AD0JA"); Assert.AreEqual(appended, expected); }
public void testAppendMultisigTransaction() { MultisigAddress addr = makeTestMsigAddr(); byte[] firstTxBytes = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAdvZ3y9GsInBPutdwKc7Jy+an13CcjSV1lcvRAYQKYOxXwfgT5B/mK14R57ueYJTYyoDO8zBY6kQmBalWkm95AIGicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxgaJwa8Qg5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKGjdGhyAqF2AaN0eG6Jo2FtdM0TiKNmZWXOAANPqKJmds4ADtbco2dlbq10ZXN0bmV0LXYzMS4womx2zgAO2sSkbm90ZcQItFF5Ofz60nGjcmN2xCAbfsCwS+pht5aQl+bL9AfhCKcFNR0LyYq+sSIJqKuBeKNzbmTEII2StImQAXOgTfpDWaNmamr86ixCoF3Zwfc+66VHgDfppHR5cGWjcGF5"); byte[] seed = Mnemonic.ToKey("since during average anxiety protect cherry club long lawsuit loan expand embark forum theory winter park twenty ball kangaroo cram burst board host ability left"); Account account = new Account(seed); byte[] appended = account.AppendMultisigTransactionBytes(addr, firstTxBytes); byte[] expected = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAdvZ3y9GsInBPutdwKc7Jy+an13CcjSV1lcvRAYQKYOxXwfgT5B/mK14R57ueYJTYyoDO8zBY6kQmBalWkm95AIKicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxoXPEQE4cdVDpoVoVVokXRGz6O9G3Ojljd+kd6d2AahXLPGDPtT/QA9DI1rB4w8cEDTy7gd5Padkn5EZC2pjzGh0McAeBonBrxCDn8PhNBoEd+fMcjYeLEVX0Zx1RoYXCAJCGZ/RJWHBooaN0aHICoXYBo3R4bomjYW10zROIo2ZlZc4AA0+oomZ2zgAO1tyjZ2VurXRlc3RuZXQtdjMxLjCibHbOAA7axKRub3RlxAi0UXk5/PrScaNyY3bEIBt+wLBL6mG3lpCX5sv0B+EIpwU1HQvJir6xIgmoq4F4o3NuZMQgjZK0iZABc6BN+kNZo2ZqavzqLEKgXdnB9z7rpUeAN+mkdHlwZaNwYXk="); Assert.AreEqual(appended, expected); }
public async void CreateMultiSig_Clicked(System.Object sender, System.EventArgs e) { // restore accounts var accounts = await helper.RestoreAccounts(); Account account1 = accounts[0]; Account account2 = accounts[1]; Account account3 = accounts[2]; List <Ed25519PublicKeyParameters> publickeys = new List <Ed25519PublicKeyParameters>(); publickeys.Add(account1.GetEd25519PublicKey()); publickeys.Add(account2.GetEd25519PublicKey()); publickeys.Add(account3.GetEd25519PublicKey()); MultisigAddress msig = new MultisigAddress(1, 2, publickeys); ulong? balance = await helper.GetAccountBalance(helper.StorageMultisig); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body><h3>" + "Multisig Address " + msig.ToString() + "</h3>" + "<h3>" + "Multisig balance = " + balance.ToString() + "</h3>" + "</body></html>"; myWebView.Source = htmlSource; CreateMultiSig.Text = "Multisig created"; CreateMultiSig.IsEnabled = false; GetMultiSig.IsVisible = true; myWebViewp.Source = htmlSource; CreateMultiSigp.Text = "Multisig created"; CreateMultiSigp.IsEnabled = false; GetMultiSigp.IsVisible = true; await SecureStorage.SetAsync(helper.StorageMultisig, msig.ToString()); buttonstate(); // OpenDispenser(helper, network, msig.ToString()); }
public void TestToString() { Address one = new Address("XMHLMNAVJIMAW2RHJXLXKKK4G3J3U6VONNO3BTAQYVDC3MHTGDP3J5OCRU"); Address two = new Address("HTNOX33OCQI2JCOLZ2IRM3BC2WZ6JUILSLEORBPFI6W7GU5Q4ZW6LINHLA"); Address three = new Address("E6JSNTY4PVCY3IRZ6XEDHEO6VIHCQ5KGXCIQKFQCMB2N6HXRY4IB43VSHI"); MultisigAddress addr = new MultisigAddress(1, 2, new List <Ed25519PublicKeyParameters> { new Ed25519PublicKeyParameters(one.Bytes, 0), new Ed25519PublicKeyParameters(two.Bytes, 0), new Ed25519PublicKeyParameters(three.Bytes, 0), }); Assert.AreEqual(addr.ToAddress().ToString(), "UCE2U2JC4O4ZR6W763GUQCG57HQCDZEUJY4J5I6VYY4HQZUJDF7AKZO5GM"); TestUtil.SerializeDeserializeCheck(addr); }
public void testSignMultisigKeyRegTransaction() { MultisigAddress addr = makeTestMsigAddr(); byte[] encKeyRegTx = Convert.FromBase64String("gaN0eG6Jo2ZlZc4AA8jAomZ2zgAO+dqibHbOAA79wqZzZWxrZXnEIDISKyvWPdxTMZYXpapTxLHCb+PcyvKNNiK1aXehQFyGo3NuZMQgjZK0iZABc6BN+kNZo2ZqavzqLEKgXdnB9z7rpUeAN+mkdHlwZaZrZXlyZWemdm90ZWtkzScQp3ZvdGVrZXnEIHAb1/uRKwezCBH/KB2f7pVj5YAuICaJIxklj3f6kx6Ip3ZvdGVsc3TOAA9CQA=="); SignedTransaction wrappedTx = Encoder.DecodeFromMsgPack <SignedTransaction>(encKeyRegTx); byte[] seed = Mnemonic.ToKey("auction inquiry lava second expand liberty glass involve ginger illness length room item discover ahead table doctor term tackle cement bonus profit right above catch"); Account account = new Account(seed); SignedTransaction stx = account.SignMultisigTransaction(addr, wrappedTx.tx); byte[] enc = Encoder.EncodeToMsgPack(stx); // check main signature is correct byte[] golden = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAujReoxR7FeTUTqgOn+rS20XOF3ENA+JrSgZ5yvrDPg3NQAzQzUXddB0PVvPRn490oVSQaHEIY05EDJXVBFPJD4GicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxgaJwa8Qg5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKGjdGhyAqF2AaN0eG6Jo2ZlZc4AA8jAomZ2zgAO+dqibHbOAA79wqZzZWxrZXnEIDISKyvWPdxTMZYXpapTxLHCb+PcyvKNNiK1aXehQFyGo3NuZMQgjZK0iZABc6BN+kNZo2ZqavzqLEKgXdnB9z7rpUeAN+mkdHlwZaZrZXlyZWemdm90ZWtkzScQp3ZvdGVrZXnEIHAb1/uRKwezCBH/KB2f7pVj5YAuICaJIxklj3f6kx6Ip3ZvdGVsc3TOAA9CQA=="); Assert.AreEqual(enc, golden); }
public void testSignMultisigTransaction() { MultisigAddress addr = makeTestMsigAddr(); // build unsigned transaction var tx = new Transaction(addr.ToAddress(), 217000, 972508, 973508, Convert.FromBase64String("tFF5Ofz60nE="), 5000, new Address("DN7MBMCL5JQ3PFUQS7TMX5AH4EEKOBJVDUF4TCV6WERATKFLQF4MQUPZTA"), "testnet-v31.0", new Digest()); byte[] seed = Mnemonic.ToKey("auction inquiry lava second expand liberty glass involve ginger illness length room item discover ahead table doctor term tackle cement bonus profit right above catch"); Account account = new Account(seed); SignedTransaction stx = account.SignMultisigTransaction(addr, tx); byte[] enc = Encoder.EncodeToMsgPack(stx); // check main signature is correct byte[] golden = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAdvZ3y9GsInBPutdwKc7Jy+an13CcjSV1lcvRAYQKYOxXwfgT5B/mK14R57ueYJTYyoDO8zBY6kQmBalWkm95AIGicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxgaJwa8Qg5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKGjdGhyAqF2AaN0eG6Jo2FtdM0TiKNmZWXOAANPqKJmds4ADtbco2dlbq10ZXN0bmV0LXYzMS4womx2zgAO2sSkbm90ZcQItFF5Ofz60nGjcmN2xCAbfsCwS+pht5aQl+bL9AfhCKcFNR0LyYq+sSIJqKuBeKNzbmTEII2StImQAXOgTfpDWaNmamr86ixCoF3Zwfc+66VHgDfppHR5cGWjcGF5"); Assert.AreEqual(enc, golden); }
public void testLogicsigMultisigSignature() { byte[] program = { 0x01, 0x20, 0x01, 0x01, 0x22 /*int 1*/ }; Address one = new Address("DN7MBMCL5JQ3PFUQS7TMX5AH4EEKOBJVDUF4TCV6WERATKFLQF4MQUPZTA"); Address two = new Address("BFRTECKTOOE7A5LHCF3TTEOH2A7BW46IYT2SX5VP6ANKEXHZYJY77SJTVM"); Address three = new Address("47YPQTIGQEO7T4Y4RWDYWEKV6RTR2UNBQXBABEEGM72ESWDQNCQ52OPASU"); MultisigAddress ma = new MultisigAddress(1, 2, new List <Ed25519PublicKeyParameters> { new Ed25519PublicKeyParameters(one.Bytes, 0), new Ed25519PublicKeyParameters(two.Bytes, 0), new Ed25519PublicKeyParameters(three.Bytes, 0), }); string mn1 = "auction inquiry lava second expand liberty glass involve ginger illness length room item discover ahead table doctor term tackle cement bonus profit right above catch"; string mn2 = "since during average anxiety protect cherry club long lawsuit loan expand embark forum theory winter park twenty ball kangaroo cram burst board host ability left"; Account acc1 = new Account(mn1); Account acc2 = new Account(mn2); Account account = new Account(); LogicsigSignature lsig = new LogicsigSignature(program); lsig = acc1.SignLogicsig(lsig, ma); Assert.AreEqual(lsig.logic, program); Assert.IsNull(lsig.args); Assert.IsNull(lsig.sig); Assert.AreNotEqual(lsig.msig, new MultisigSignature()); Assert.IsNotNull(lsig.msig); var verified = lsig.Verify(ma.ToAddress()); Assert.IsFalse(verified); LogicsigSignature lsigLambda = lsig; //Assert.AreEqualThrownBy(()->account.appendToLogicsig(lsigLambda)) // .isInstanceOf(IllegalArgumentException.class) // .hasMessage("Multisig account does not contain this secret key"); lsig = acc2.AppendToLogicsig(lsig); verified = lsig.Verify(ma.ToAddress()); Assert.IsTrue(verified); // Add a single signature and ensure it fails LogicsigSignature lsig1 = new LogicsigSignature(program); lsig1 = account.SignLogicsig(lsig1); lsig.sig = lsig1.sig; verified = lsig.Verify(ma.ToAddress()); Assert.IsFalse(verified); verified = lsig.Verify(account.Address); Assert.IsFalse(verified); // Remove and ensure it still works lsig.sig = null; verified = lsig.Verify(ma.ToAddress()); Assert.IsTrue(verified); // check serialization byte[] outBytes = Encoder.EncodeToMsgPack(lsig); LogicsigSignature lsig2 = Encoder.DecodeFromMsgPack <LogicsigSignature>(outBytes); Assert.AreEqual(lsig2, lsig); verified = lsig2.Verify(ma.ToAddress()); Assert.IsTrue(verified); TestUtil.SerializeDeserializeCheck(lsig2); }
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; //} }
public static void Main(params string[] args) { string algodApiAddrTmp = args[0]; if (algodApiAddrTmp.IndexOf("//") == -1) { algodApiAddrTmp = "http://" + algodApiAddrTmp; } string ALGOD_API_ADDR = algodApiAddrTmp; string ALGOD_API_TOKEN = args[1]; // AlgodClient client = new AlgodClient().SetBasePath(ALGOD_API_ADDR); //ApiKeyAuth api_key = (ApiKeyAuth)client.getAuthentication("api_key"); //api_key.setApiKey(ALGOD_API_TOKEN); AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN); //MultisigTransaction // List for Pks for multisig account List <Ed25519PublicKeyParameters> publicKeys = new List <Ed25519PublicKeyParameters>(); // Create 3 random new account Account act1 = new Account("solve gravity slight leader net silver enlist harsh apple shoulder question child material network lumber lion wagon filter cabin shoot raven barely next abandon tired"); Account act2 = new Account("scan acoustic prefer duck this error intact blush nominee woman retreat install picture lion fruit consider sail basic kind owner grocery ginger piece abandon wife"); Account act3 = new Account("advance main into silver law unfold cable indoor hockey legend chat pelican hobby knock symptom until travel olive quality melody toast pizza inspire absorb limit"); string DEST_ADDR = "KV2XGKMXGYJ6PWYQA5374BYIQBL3ONRMSIARPCFCJEAMAHQEVYPB7PL3KU"; publicKeys.Add(act1.GetEd25519PublicKey()); publicKeys.Add(act2.GetEd25519PublicKey()); publicKeys.Add(act3.GetEd25519PublicKey()); // Instantiate the the Multisig Accout MultisigAddress msa = new MultisigAddress(1, 2, publicKeys); Console.WriteLine("Multisignature Address: " + msa.ToString()); Console.WriteLine("no algo in the random adress, use TestNet Dispenser to add funds"); //no algo in the random adress, use TestNet Dispenser to add funds //Console.ReadKey(); // add some notes to the transaction byte[] notes = Encoding.UTF8.GetBytes("These are some notes encoded in some way!");//.getBytes(); //ulong? feePerByte; //string genesisID; //Digest genesisHash; //ulong? firstRound = 0; //Algorand.Algod.Client.Model.TransactionParams transParams = null; var amount = Utils.AlgosToMicroalgos(1); Transaction tx = null; try { tx = Utils.GetPaymentTransaction(new Address(msa.ToString()), new Address(DEST_ADDR), amount, "this is a multisig trans", algodApiInstance.TransactionParams()); } catch (Exception e) { Console.WriteLine("Could not get params", e.Message); } //BigInteger amount = BigInteger.valueOf(2000000); //BigInteger lastRound = firstRound.add(BigInteger.valueOf(1000)); // 1000 is the max tx window // Setup Transaction // Use a fee of 0 as we will set the fee per // byte when we sign the tx and overwrite it //var tx = Utils.GetPaymentTransaction(new Address(msa.ToString()), new Address(DEST_ADDR), amount, "this is a multisig trans", transParams); //Transaction tx = new Transaction(new Address(msa.ToString()), transParams.Fee, transParams.LastRound, transParams.LastRound + 1000, // notes, amount, new Address(DEST_ADDR), transParams.GenesisID, new Digest(transParams.Genesishashb64)); // Sign the Transaction for two accounts SignedTransaction signedTx = act1.SignMultisigTransaction(msa, tx); SignedTransaction completeTx = act2.AppendMultisigTransaction(msa, signedTx); // send the transaction to the network try { var id = Utils.SubmitTransaction(algodApiInstance, completeTx); Console.WriteLine("Successfully sent tx with id: " + id); } catch (ApiException e) { // This is generally expected, but should give us an informative error message. Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message); } Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist."); Console.ReadKey(); }