コード例 #1
0
        public void SpentSegwitPaymentTxByBob(BitcoinBasedCurrency currency)
        {
            const int paymentQty = 3000;

            var paymentTx        = SignSegwitPaymentTxAlice2Bob(currency);
            var paymentTxOutputs = paymentTx.Outputs
                                   .Where(o => o.Value == paymentQty)
                                   .ToArray();

            var spentTx = currency.CreateP2WPkhTx(
                unspentOutputs: paymentTxOutputs,
                destinationAddress: Common.Bob
                .PubKey
                .GetSegwitAddress(currency.Network)
                .ToString(),
                changeAddress: Common.Bob
                .PubKey
                .GetSegwitAddress(currency.Network)
                .ToString(),
                amount: 2000,
                fee: 1000);

            spentTx.Sign(Common.Bob, paymentTxOutputs);

            Assert.True(spentTx.Verify(paymentTxOutputs));
        }
コード例 #2
0
 public static IBitcoinBasedTransaction CreateSegwitPaymentTx(
     BitcoinBasedCurrency currency,
     IEnumerable <ITxOutput> outputs,
     PubKey from,
     PubKey to,
     int amount,
     int fee)
 {
     return(currency.CreateP2WPkhTx(
                unspentOutputs: outputs,
                destinationAddress: to.GetSegwitAddress(currency.Network).ToString(),
                changeAddress: from.GetSegwitAddress(currency.Network).ToString(),
                amount: amount,
                fee: fee));
 }