コード例 #1
0
        private static (Transaction, Coin[]) CreateTransaction(params Coin[] coins)
        {
            if (coins is null || coins.Length == 0)
            {
                coins = Enumerable.Range(0, 10).Select(_ => new Coin(RandomUtils.GetUInt256(), 0u, Money.Coins(10), Script.Empty)).ToArray();
            }
            var tx = Network.RegTest.CreateTransaction();

            foreach (var coin in coins)
            {
                tx.Inputs.Add(coin.Outpoint, Script.Empty, WitScript.Empty);
            }
            tx.Outputs.Add(Money.Coins(3), Script.Empty);
            tx.Outputs.Add(Money.Coins(2), Script.Empty);
            tx.Outputs.Add(Money.Coins(1), Script.Empty);
            tx.PrecomputeHash(true, false);
            return(tx, tx.Outputs.AsCoins().ToArray());
        }