Как транслировать транзакцию NBitcoin с несколькими TxIn (входные данные транзакции)

Я бегу по TestNet. Я пытаюсь добавить несколько входов транзакции TxIn(), чтобы тратить от этих входов. Когда я транслирую свою транзакцию, она возвращается успешно, но я не вижу ее в проводнике блоков. Я обработал транзакцию с помощью одного TxIn(), и когда я транслировал ее, она прошла успешно, и я смог просмотреть ее в проводнике блоков. Я был на этом более 2 дней. Буду очень признателен за вашу помощь, ребята

var bitcoinPrivateKey = new BitcoinSecret("cNZupUgfs54DmsShwxa1wpomQcszUtuJYFvx9zWPbXrT7KsWtiUd");
        var network = bitcoinPrivateKey.Network;
        var address = bitcoinPrivateKey.GetAddress();
        var client = new QBitNinjaClient(network);
        var balance = client.GetBalance(address).Result;

        var transactionId = uint256.Parse("06c0aec7543467951abad0c28998a2c1fc1cdc34e01113f8ec1fdb22be854771");
        var transactionResponse = client.GetTransaction(transactionId).Result;

        var tx = new Transaction();
        foreach (var operation in balance.Operations)
        {
            OutPoint spendOutPoint = null;

            var coinsReceived = operation.ReceivedCoins;
            foreach (var coin in coinsReceived)
            {
                if (coin.TxOut.ScriptPubKey == bitcoinPrivateKey.ScriptPubKey)
                {
                    spendOutPoint = coin.Outpoint;
                    tx.Inputs.Add(new TxIn()
                    {
                        PrevOut = spendOutPoint
                    });
                }
            }


        }
        var chimaTestDestinationAddress = new BitcoinPubKeyAddress("mxgN2AiqHjKfGvo6Y57fAe4Y754rPdKf4P");
        TxOut chimaTestDestinationAddressTxOut = new TxOut()
        {
            Value = new Money((decimal)0.50, MoneyUnit.BTC),
            ScriptPubKey = chimaTestDestinationAddress.ScriptPubKey
        };
        TxOut ugoChangeBackTxOut = new TxOut()
        {
            Value = new Money((decimal)2.98, MoneyUnit.BTC),
            ScriptPubKey = bitcoinPrivateKey.ScriptPubKey
        };
        tx.Outputs.Add(chimaTestDestinationAddressTxOut);
        tx.Outputs.Add(ugoChangeBackTxOut);
        var msg = "ugo the jedi master";
        var msgBytes = Encoding.UTF8.GetBytes(msg);

        TxOut txDesc = new TxOut()
        {
            Value = Money.Zero,
            ScriptPubKey = TxNullDataTemplate.Instance.GenerateScriptPubKey(msgBytes)
        };
        tx.Outputs.Add(txDesc);


        tx.Inputs[0].ScriptSig = bitcoinPrivateKey.PubKey.WitHash.ScriptPubKey;
        tx.Inputs[1].ScriptSig = bitcoinPrivateKey.PubKey.WitHash.ScriptPubKey;
        tx.Inputs[2].ScriptSig = bitcoinPrivateKey.PubKey.WitHash.ScriptPubKey;
        tx.Inputs[3].ScriptSig = bitcoinPrivateKey.PubKey.WitHash.ScriptPubKey;
        tx.Inputs[4].ScriptSig = bitcoinPrivateKey.PubKey.WitHash.ScriptPubKey;
        tx.Sign(bitcoinPrivateKey, false);

        BroadcastResponse broadcast = client.Broadcast(tx).Result;
        if (!broadcast.Success)
        {
            Console.WriteLine("ErrorCode: " + broadcast.Error.ErrorCode);
            Console.WriteLine("Error message: " + broadcast.Error.Reason);
        }
        else
        {
            Console.WriteLine("Success, you can now checkout the transaction in any block explorer");
            Console.WriteLine("Hash: " + tx.GetHash());
        }

0 ответов

Другие вопросы по тегам