Неверный пропущенный ввод nbitcoin - PullRequest
0 голосов
/ 12 сентября 2018

Я строю биткойн-кошелек и получаю ошибку Invalid: Missing Input.

Вот пример кода

var transaction = new Transaction();

List<NBitcoin.ICoin> receivedCoins = new List<NBitcoin.ICoin>();

OutPoint outPointToSpend = null;
if (balance.Operations.Count > 0)
{
    foreach (var operation in balance.Operations)
    {
            foreach (Coin receivedCoin in operation.ReceivedCoins)
            {
                outPointToSpend = receivedCoin.Outpoint;
                {
                    if (receivedCoin.TxOut.ScriptPubKey == mk.ScriptPubKey)
                    {
                        outPointToSpend = receivedCoin.Outpoint;
                    }
                }

                if (outPointToSpend == null)
                    throw new Exception("TxOut doesn't contain our ScriptPubKey");

                transaction.Inputs.Add(new TxIn() { PrevOut = outPointToSpend });

                receivedCoins.Add(receivedCoin);
            }

Кажется, все работает, и я не получаю еще одну ошибку. Вот еще и Строитель транзакций.

TransactionBuilder builder = new TransactionBuilder();
var tx = builder
            .AddCoins(receivedCoins)
            .AddKeys(mk)
            .Send(Stranger, Money.Coins(k))
            .SetChange(mk)
            .SendFees(Money.Coins(0.0001m))
            .BuildTransaction(sign: true);

Есть мысли?

Это не ошибка компиляции. Я получаю сообщение об ошибке при сборке проекта в MessageBox, ErrorCode: и сообщении об ошибке:

BroadcastResponse broadcastResponse = client.Broadcast(tx).Result;
if (!broadcastResponse.Success)
{
    MessageBox.Show("ErrorCode: " + broadcastResponse.Error.ErrorCode);
    MessageBox.Show("Error message: " + broadcastResponse.Error.Reason);
}
else
{
    MessageBox.Show("Success! You can check out the hash of the transaciton in any block explorer:");
    Console.WriteLine(tx.GetHash());
}
...