Sunday, December 22, 2024

Multi-Sig Transaction not broadcasting error – Script evaluated with out error however completed with a false/empty prime stack factor

Making an attempt to provide a multi-sig transaction. I’ve this to date.

Despatched funds to : 2NDYqQujvtycWCvs7kjtHE9U3xWPsuaiXrG
https://mempool.area/testnet4/handle/2NDYqQujvtycWCvs7kjtHE9U3xWPsuaiXrG

I suppose firstly was that the flawed handle to ship to?

Right here is my tx hash:
010000000114bc1ab21ce478083eaacf55ce9442bc1b130bff443410f590b399d18d701ecc01000000fc00473044022013a2bc5d4d3f88bbbfb94fe29b43a69987b00a94093b8ddbf41c1a2e9b26f75a02206fbf1e3607f9287f4879a1f5822ae52338f610b5ee022ff53e083e0bf0dab0220147304402204ce389e1def4ea314c09bbd29c6f294bf7f401cc70c25c3e8debe291a9d232ef022073bab094326dcbed6cb10435768e53144927a4cf84ea0c7bf76b341e0d55fef9014c6952210319dcb49b83195a399a0530d2d40f86861a2e64dbf2f71ad63cd5caf1d1901ff82103a30e878456b11b5c30faa8aa90a7243d7bec78b5b8e181194c2d942cd943eadd210397e9ffb403fbd47bbfd04c8773388e8df4040621ad57bc8112dfe5f294f166a753aefdffffff022602000000000000160014945a3408d2f7cd07b7d1defbda62992481601d8e389d07000000000017a914deb72871a21fe9d480912890734e014c0b4273338700000000

I wrote this code to provide all this:

void Most important()
{
    Community community = Community.TestNet4;
    byte[] key1Bytes = ("Eliminated").HexToByteArray();
    byte[] key2Bytes = ("Eliminated").HexToByteArray();
    byte[] key3Bytes = ("Eliminated").HexToByteArray();
    
    Key key1 = new Key(key1Bytes);
    Key key2 = new Key(key2Bytes);
    Key key3 = new Key(key3Bytes);

    // Create a 2-of-3 multi-sig script
    Script scriptPubKey   = PayToMultiSigTemplate.Occasion.GenerateScriptPubKey(2, new[] { key1.PubKey, key2.PubKey, key3.PubKey });
    Script redeemScript = scriptPubKey.PaymentScript;
    
    //Get deposit handle '2NDYqQujvtycWCvs7kjtHE9U3xWPsuaiXrG'
    BitcoinAddress multiSigAddress = redeemScript.Hash.GetAddress(community);
    var sender = multiSigAddress.ToString();

    Console.WriteLine("Multi-Sig Handle: " + multiSigAddress);
    //cc1e708dd199b390f5103444ff0b131bbc4294ce55cfaa3e0878e41cb21abc14
    //cc0bdc3c691c263407b1060169d44fc2c59b004cd182e6aa72873f0cc389dd96
    //vout 1
    

    OutPoint outPoint = new OutPoint(uint256.Parse("cc1e708dd199b390f5103444ff0b131bbc4294ce55cfaa3e0878e41cb21abc14"), 1);
    Coin coin = new Coin(outPoint, new TxOut(Cash.Satoshis(500_000m), redeemScript));
    ScriptCoin coinToSpend = new ScriptCoin(coin, scriptPubKey);
    
    
    var txInAmount = coinToSpend.Quantity;
    var minerFee = new Cash(450, MoneyUnit.Satoshi);
    var sendAmount = new Cash(0.00001M, MoneyUnit.BTC);
    var totalSpend = sendAmount - minerFee;

    // Vacation spot handle
    BitcoinAddress recipientAddress = BitcoinAddress.Create("tb1qj3drgzxj7lxs0d73mmaa5c5eyjqkq8vwjx7xak", community);

    // Create the transaction
    TransactionBuilder builder = community.CreateTransactionBuilder();
    TransactionBuilder builderForKey1 = community.CreateTransactionBuilder();
    TransactionBuilder builderForKey2 = community.CreateTransactionBuilder();

    NBitcoin.Transaction unsigned = builder
        .AddCoins(coinToSpend)
        .Ship(recipientAddress, totalSpend)
        .SendFees(minerFee)
        .SetChange(multiSigAddress)
        .SetOptInRBF(true)
        .BuildTransaction(false);

    NBitcoin.Transaction key1Signed =
        builderForKey1
        .AddCoins(coinToSpend)
        .AddKeys(key1)
        .SignTransaction(unsigned);

    NBitcoin.Transaction key2Signed =
        builderForKey2
        .AddCoins(coinToSpend)
        .AddKeys(key2)
        .SignTransaction(key1Signed);

    NBitcoin.Transaction fullySigned =
        builder
        .AddCoins(coinToSpend)
        .CombineSignatures(key1Signed, key2Signed);


    var txVerified = builder.Confirm(fullySigned);
    var outcome = fullySigned.Verify();


    txVerified.Dump();
        outcome.Dump();

    var hexTx = fullySigned.ToHex();
    var hashTX = fullySigned.GetHash();
    hexTx.Dump();

    //Console.WriteLine(fullySigned);

//  var hexTx = fullySigned.ToHex();
//  var hashTX = fullySigned.GetHash();
//
//  hexTx.Dump();
    //BroadcastTransaction(fullySigned);
}
public static decimal BTCMultiplier = 100_000_000M;

void BroadcastTransaction(NBitcoin.Transaction transaction)
{
    utilizing (var node = Node.Join(Community.TestNet4, "Eliminated"))
    {
        node.VersionHandshake();
        node.SendMessage(new InvPayload(InventoryType.MSG_TX, transaction.GetHash()));
        node.SendMessage(new TxPayload(transaction));
        Thread.Sleep(500); // Wait a bit to make sure the transaction is shipped
    }
}

public static class MyExtensions
{
    public static byte[] HexToByteArray(this string hex)
    {
        var bytes = Enumerable.Vary(0, hex.Size / 2)
                .Choose(x => Convert.ToByte(hex.Substring(x * 2, 2), 16))
                .ToArray();

        return bytes;
    }
}

I’m form of at a loss and the transaction passes each the confirm and the examine, however once I go to broadcast in CLI I get Script evaluated with out error however completed with a false/empty prime stack factor)

Any assistance is appreciated.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles