Esempio n. 1
0
 /// <summary>
 /// Sending possibly many types coins to possibly many addresses, in one single transaction
 /// </summary>
 /// <param name="destinations"></param>
 /// <param name="memo"></param>
 /// <returns></returns>
 public BroadcastResponse MultiSend(List <MultipleSendDestination> destinations, string memo = "")
 {
     //Ensure no other broadcast transaction interferes with sequence until it hit the blockchain
     lock (BroadcastLockObject)
     {
         if (VerifySequenceBeforeSend)
         {
             Wallet.RefreshSequence();
         }
         var msg    = BroadcastMessageBuilder.BuildSendMultipleMessage(destinations, Wallet, memo);
         var result = HTTP.BroadcastToBlockchain(msg, WaitForTransactionConfirmationOnBroadcast);
         if (result.ok)
         {
             _wallet.IncrementSequence();
         }
         return(result);
     }
 }
Esempio n. 2
0
        public void BuildSendMultipleMessageTest()
        {
            Wallet w = new Wallet("1E5B4C6DDDB2BDD6B40344808812D6D3254D7D4E105A52BA51C032EB7BAC1035", Network.Test);

            w.SetSequence(0);//Have to reset, wallet automatically refreshes it's sequence on creation
            List <MultipleSendDestination> destinations = new List <MultipleSendDestination>();

            destinations.Add(new MultipleSendDestination {
                Address = "tbnb1qqy83vaerqz7yv4yfqtz8pt0gl0wssxyl826h4", Amount = (decimal)0.3, coin = "BNB"
            });
            destinations.Add(new MultipleSendDestination {
                Address = "tbnb17fq8s55rdshy04zjq0lfkexs4jeclmfnaaa2f2", Amount = (decimal)0.12, coin = "BNB"
            });
            var msgBytes    = BroadcastMessageBuilder.BuildSendMultipleMessage(destinations, w, "Hello");
            var msgStr      = BitConverter.ToString(msgBytes).Replace("-", "").ToUpper();
            var expectedStr = "ED01F0625DEE0A702A2C87FA0A220A141B0A2CFFAE1193EE0BDE3E01C62E34D82E3BFA0A120A0A03424E421080BD831412220A14000878B3B91805E232A4481623856F47DEE840C4120A0A03424E42108087A70E12220A14F2407852836C2E47D45203FE9B64D0ACB38FED33120A0A03424E421080B6DC05126E0A26EB5AE9872103D2B6A5194D34703971E6C7544B2E5CE687AF7CF58346F662936D8E26C20A301312406F4528E91293C969422CED4B8879AA54738B3A253E012DC5EC17AFEDA9FB09DA692DA436570A5B374994BF1B17F8FFB96D1EEAD3481EAF4DADAE6F7A246D66C718ECE0281A0548656C6C6F";

            Assert.AreEqual(msgStr, expectedStr);
        }