Close Menu
  • Home
  • Bitcoin
    • Bitcoin Atm Machines
    • Bitcoin Books
      • Bitcoin Jobs
        • Bitcoin Price Prediction
        • Bitcoin Coin
  • Bitcoin Farm
  • Bitcoin Gifts
    • Bitcoin Gift Card
    • Bitcoin Mining
    • Bitcoin Wallets
  • Technology
  • Shop
    • Bitcoin Atm Machine
    • Bitcoin Coins
    • Bitcoin Coins, Wallets,Shirts,Books,Gifts
    • Bitcoin Mining Machine
    • Bitcoin Mining Machine Full Set Up
    • Computers and Accessories
    • USB Flash Drives
    • Mini Bitcoin Mining Machine
What's Hot

Artificial Superintelligence Alliance Whales Purchase Mpeppe (MPEPE) Before Its Enters Stage 4

March 18, 2025

Tesla’s China Rivals Report Steady August Sales Performance Amid Intense Price Competition: What Investors Should Know – XPeng (NYSE:XPEV), NIO (NYSE:NIO), Li Auto (NASDAQ:LI)

March 18, 2025

IEEE President’s Note: Why Students Should Stay with IEEE

March 18, 2025
Facebook X (Twitter) Instagram
  • Bitcoin
  • Bitcoin Books
  • Bitcoin Coin
  • Bitcoin Farm
  • Bitcoin Gift Card
Facebook X (Twitter) Instagram
farm-bitcoin.com
  • Home
  • Bitcoin
    • Bitcoin Atm Machines
    • Bitcoin Books
      • Bitcoin Jobs
        • Bitcoin Price Prediction
        • Bitcoin Coin
  • Bitcoin Farm
  • Bitcoin Gifts
    • Bitcoin Gift Card
    • Bitcoin Mining
    • Bitcoin Wallets
  • Technology
  • Shop
    • Bitcoin Atm Machine
    • Bitcoin Coins
    • Bitcoin Coins, Wallets,Shirts,Books,Gifts
    • Bitcoin Mining Machine
    • Bitcoin Mining Machine Full Set Up
    • Computers and Accessories
    • USB Flash Drives
    • Mini Bitcoin Mining Machine
farm-bitcoin.com
Home » bitcoinj – spend founds from p2wsh address,non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)
bitcoinj – spend founds from p2wsh address,non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)
Bitcoin

bitcoinj – spend founds from p2wsh address,non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)

adminBy adminMarch 18, 2025No Comments2 Mins Read
Share
Facebook Twitter LinkedIn Pinterest Email


i want spent coin from p2wsh address on btc testnet3 network, i use bitcoinj 0.15.2 build transaction and sign it, use 2/3 multiSig

when i send raw transaction by bitcoin core 0.17.0 command line by use ./bitcoin-cli sendrawtransaction, i get error

error code: -26
error message:non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)

For now, I don’t known why my signed tx broadcast fali?
please help me,Thanks in advance.

relevant information

private_key1:cUkNoCzNXMXzN4JhYYbgiWAaKQEwfgUAzW2kogRNhUqGaiZ2AdUh
private_key2:cUpdkS6ekPkQj1RJWtjbLbYyDwszb3nEBbRkeRf9QHVkBBijEdgv
private_key3:cU4tWJk3BGymoJgbGbxNA6NJapTwrbfWWaPsz1bCZBzkoeszb4ML

p2wsh address:tb1qrgwja0j7447fz66gufzuj4awed63xm5xpgs57qwpmm0ujc0x7vusdrjmw6

witness script str:2 PUSHDATA(33)[037a5929bacc6251ace6fb688c7de760b047f03ef1d23f86bbbf61c152c16a4409] PUSHDATA(33)[02764c145abc62bf1c3786136c7020b4cef227102f458aa607afc6afda7b578ce6] PUSHDATA(33)[02f06485529af46c93b4bd6ab68f44dc58241176a989cca77fe052644a7602d048] 3 CHECKMULTISIG

witness script encode str:5221037a5929bacc6251ace6fb688c7de760b047f03ef1d23f86bbbf61c152c16a44092102764c145abc62bf1c3786136c7020b4cef227102f458aa607afc6afda7b578ce62102f06485529af46c93b4bd6ab68f44dc58241176a989cca77fe052644a7602d04853ae

witness hash:0 PUSHDATA(32)[1a1d2ebe5ead7c916b48e245c957aecb75136e860a214f01c1dedfc961e6f339]

witness hash encode str:00201a1d2ebe5ead7c916b48e245c957aecb75136e860a214f01c1dedfc961e6f339

signed transaction

01000000000101282f723b362a588f35fee66719c8d739779942b3401995e8e7b3b1f062188c390000000000ffffffff01c8af0000000000002200201a1d2ebe5ead7c916b48e245c957aecb75136e860a214f01c1dedfc961e6f3390400483045022100d6373e87fcebb273c08496e042856acf8068c8685ab3f387151caffb957a828802206ee1488853578b58bdeaba3d47470e2bf58d5a3592b610e505fb31c6cc0f1e780147304402202e9b5c156fef699d9d1c60a22be863a4eb08f01fe86592ade3847d7e7ff9d6b9022077557ce221915b3e2b7c995ba994737f7214a68a0accf6ebb4a259224bc778d601695221037a5929bacc6251ace6fb688c7de760b047f03ef1d23f86bbbf61c152c16a44092102764c145abc62bf1c3786136c7020b4cef227102f458aa607afc6afda7b578ce62102f06485529af46c93b4bd6ab68f44dc58241176a989cca77fe052644a7602d04853ae00000000

the decode raw transaction

{
"txid": "45bb61b82eb70f8d1d52edde904b3402d677910ffdcb987264ec58b44eac525a",
"hash": "4b818b6745f45fdd79f0f54222206ee35de27eb103b8974046e6f6b8a323d2b4",
"version": 1,
"size": 349,
"vsize": 158,
"weight": 631,
"locktime": 0,
"vin": [
{
"txid": "398c1862f0b1b3e7e8951940b342997739d7c81967e6fe358f582a363b722f28",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"",
"3045022100d6373e87fcebb273c08496e042856acf8068c8685ab3f387151caffb957a828802206ee1488853578b58bdeaba3d47470e2bf58d5a3592b610e505fb31c6cc0f1e7801",
"304402202e9b5c156fef699d9d1c60a22be863a4eb08f01fe86592ade3847d7e7ff9d6b9022077557ce221915b3e2b7c995ba994737f7214a68a0accf6ebb4a259224bc778d601",
"5221037a5929bacc6251ace6fb688c7de760b047f03ef1d23f86bbbf61c152c16a44092102764c145abc62bf1c3786136c7020b4cef227102f458aa607afc6afda7b578ce62102f06485529af46c93b4bd6ab68f44dc58241176a989cca77fe052644a7602d04853ae"
],
"sequence": 4294967295
}
],
"vout": [
{
"value": 0.00045000,
"n": 0,
"scriptPubKey": {
"asm": "0 1a1d2ebe5ead7c916b48e245c957aecb75136e860a214f01c1dedfc961e6f339",
"hex": "00201a1d2ebe5ead7c916b48e245c957aecb75136e860a214f01c1dedfc961e6f339",
"reqSigs": 1,
"type": "witness_v0_scripthash",
"addresses": [
"tb1qrgwja0j7447fz66gufzuj4awed63xm5xpgs57qwpmm0ujc0x7vusdrjmw6"
]
}
}
]
}

the sign code

public void sign() {
NetworkParameters params = TestNet3Params.get();
Coin fee = Coin.SATOSHI.times(5000L);
Coin fundAmount = Coin.SATOSHI.times(50000L);

List ecKeyList = Arrays.asList(
    DumpedPrivateKey.fromBase58(params, "cUkNoCzNXMXzN4JhYYbgiWAaKQEwfgUAzW2kogRNhUqGaiZ2AdUh").getKey(),
    DumpedPrivateKey.fromBase58(params, "cUpdkS6ekPkQj1RJWtjbLbYyDwszb3nEBbRkeRf9QHVkBBijEdgv").getKey(),
    DumpedPrivateKey.fromBase58(params, "cU4tWJk3BGymoJgbGbxNA6NJapTwrbfWWaPsz1bCZBzkoeszb4ML").getKey()
);

List inTxidList = Arrays.asList(
    "398c1862f0b1b3e7e8951940b342997739d7c81967e6fe358f582a363b722f28"
);

List inTxIndexList = Arrays.asList(
    0
);

String redeemScriptStr = "5221037a5929bacc6251ace6fb688c7de760b047f03ef1d23f86bbbf61c152c16a44092102764c145abc62bf1c3786136c7020b4cef227102f458aa607afc6afda7b578ce62102f06485529af46c93b4bd6ab68f44dc58241176a989cca77fe052644a7602d04853ae";

Script script = new Script(Utils.HEX.decode(redeemScriptStr));
Script p2wshScript = ScriptBuilder.createP2WSHOutputScript(script);

Transaction tx = new Transaction(params);
for (int i = 0; i < inTxidList.size(); i++) {
    TransactionWitness witness = new TransactionWitness(3);

    tx.addInput(Sha256Hash.wrap(inTxidList.get(i)), inTxIndexList.get(i), new Script(new byte[0]));

    Sha256Hash sigHash = tx.hashForWitnessSignature(i, p2wshScript, fundAmount, Transaction.SigHash.ALL, false);

    for (int j = 1; j < ecKeyList.size(); j++) {
        ECKey.ECDSASignature sig = ecKeyList.get(j).sign(sigHash);
        TransactionSignature txSig = new TransactionSignature(sig, Transaction.SigHash.ALL, false);

        witness.setPush(j, txSig.encodeToBitcoin());
    }
    witness.setPush(ecKeyList.size(), script.getProgram());

    tx.getInput(i).setWitness(witness);
}

Address sendTo = Address.fromString(params, "tb1qrgwja0j7447fz66gufzuj4awed63xm5xpgs57qwpmm0ujc0x7vusdrjmw6");
Coin outAmount = fundAmount.minus(fee);
Script outPkScript = ScriptBuilder.createOutputScript(sendTo);
tx.addOutput(outAmount, outPkScript);

log.info("signed tx:{}",Utils.HEX.encode(tx.bitcoinSerialize()));
}



Source link

Post Views: 40
addressnonmandatoryscriptverifyflag Bitcoinj CHECKMULTISIG Code failed founds operation P2WSH signature Spend
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
admin
  • Website

Related Posts

Artificial Superintelligence Alliance Whales Purchase Mpeppe (MPEPE) Before Its Enters Stage 4

March 18, 2025

PEPE Whales Set Out To Be Bullish With FOLKI and Mpeppe (MPEPE) With 500x Gains Between Them

March 18, 2025

private key – Safest way of long term holding

March 18, 2025

Restoring trust and equity in the digital age through decentralized AI

March 18, 2025
Add A Comment
Leave A Reply Cancel Reply

Subscribe to Updates

Get the latest creative news from farm-bitcoin about crypto, bitcoin, business and technology.

Please enable JavaScript in your browser to complete this form.
Loading
About Us
About Us

At Farm Bitcoin, we are passionate about unlocking the potential of cryptocurrency and blockchain technology. Our mission is to make the world of digital currencies accessible and understandable for everyone, from beginners to seasoned investors. We believe that cryptocurrency represents the future of finance, and we are here to guide you through this exciting landscape.

Top Insights

Artificial Superintelligence Alliance Whales Purchase Mpeppe (MPEPE) Before Its Enters Stage 4

March 18, 2025

Tesla’s China Rivals Report Steady August Sales Performance Amid Intense Price Competition: What Investors Should Know – XPeng (NYSE:XPEV), NIO (NYSE:NIO), Li Auto (NASDAQ:LI)

March 18, 2025

IEEE President’s Note: Why Students Should Stay with IEEE

March 18, 2025
Get Informed

Subscribe to Updates

Get the latest creative news from farm-bitcoin about crypto, bitcoin, business and technology.

Please enable JavaScript in your browser to complete this form.
Loading
Facebook X (Twitter) Instagram Pinterest
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions
Copyright 2024 Farm Bitcoin Design By Prince Ayaan.

Type above and press Enter to search. Press Esc to cancel.

Go to mobile version