我现在想弄清楚这三天。我认为我的问题不在于交易构建器,而在于.AddCoins
部分。
TransactionBuilder builder = Network.TestNet.CreateTransactionBuilder();
var transaction = builder
.AddCoins(coins)
.AddKeys(myPrivateKey)
.Send(addressThatIamSendingTo, Money.Coins(amountToSend))
.SetChange(addressThatIamSendingFrom);
var fee = transaction.EstimateFees(new FeeRate(1m));
var finalTransaction = transaction.SendFees(fee).BuildTransaction(true);
我的硬币.AddCoins
来自这里:
var balance = client.GetBalance(myBtcAddress); // client is from QBitNinjaClient client = new QBitNinjaClient(Network.TestNet);
var sum = 0m;
foreach (var operation in balance.Result.Operations)
{
sum += operation.Amount.ToDecimal(MoneyUnit.BTC);
}
Console.WriteLine("Sum {0} is ", sum);
var amountToSend = 0.0002m;
var transaction = Network.TestNet.CreateTransaction();
transaction.Outputs.Add(new TxOut(Money.Coins(sum), myScriptPubKey));
Coin[] coins = transaction.Outputs.AsCoins().ToArray();
事情是这样builder.Verify(finalTransaction)
说的,但是在使用或配置为命中的True
广播之后,我得到了交易 ID,我在任何地方都看不到它,并且 BTC 没有被转移。QBitNinja
Local Node
TestNet