• About
  • FAQ
  • Earn Bitcoin while Surfing the net
  • Buy & Sell Crypto on Paxful
Newsletter
Approx Foundation
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
Approx Foundation
No Result
View All Result
Home Bitcoin

Getting error “non-mandatory-script-verify-flag (Witness program hash mismatch)” when trying to send raw signed transaction

Moussa by Moussa
March 22, 2024
in Bitcoin
0
peer discovery – how to obtain the IP addresses of nodes for mining pools?
189
SHARES
1.5k
VIEWS
Share on FacebookShare on Twitter


I’m trying to send a fairly simple segwit transaction with multiple input and outputs using bitcoinlib, here’s how the simplified code looks like:

from bitcoinlib.transactions import Output, Key, Transaction

# (prev_txid, output_n, address, value in satoshis)
inputs = [
    (u'4ab923ee400a3899dc0790c7658af9931e54fc40dc1a8a79281a989e6a56ddd2', 125, 'bc1p0val59xpljwfr52hdg667v0nnnjzusfmvgys6warv7hklrfjum7sjgj75j', 1077938),
]

outputs = []
outputs.append(Output(15260, address="bc1pylrxedd66287hl0e000qy9c86u9tagg206yvyymp4j2c6c5npfjseyjpdu"))

 # 1000 = 10.00 sat/vB
fee_per_kb = 1000

t = Transaction(outputs=outputs, witness_type="segwit", version=2)

for ti in inputs:
    ki = Key("PRIVATE_KEY")
    t.add_input(prev_txid=ti[0], output_n=ti[1], address=ti[2], value=ti[3],  keys=ki.public(), witness_type="segwit")

fee = round((t.estimate_size(1) * fee_per_kb) / 100)

total_inputs = 0
for ti in inputs:
    total_inputs += ti[3]

total_output = 15260
change = total_inputs - total_output - fee

# Add change output
t.add_output(change, address="bc1pyr9x8f7z5t9cxykfzzx66y2xc3davshzmd3xmf9dcxdpkg4tjuusschhpq")

icount = 0
for ti in inputs:
    ki = Key("PRIVATE_KEY")
    t.sign(ki.private_byte, icount)
    icount += 1

t.update_totals()
t.verify()
t.info()
print()
print("Raw Signed Transaction: %s" % t.raw_hex())
Transaction b2b765f26c3d8f766e205f1ae4bd82950f6283013ed23c0dd6d337c15b30d97a
Date: None
Network: bitcoin
Version: 2
Witness type: segwit
Status: new
Verified: True
Inputs
- bc1p0val59xpljwfr52hdg667v0nnnjzusfmvgys6warv7hklrfjum7sjgj75j 0.01077938 BTC 4ab923ee400a3899dc0790c7658af9931e54fc40dc1a8a79281a989e6a56ddd2 125
  segwit sig_pubkey; sigs: 1 (1-of-1) valid
Outputs
- bc1pylrxedd66287hl0e000qy9c86u9tagg206yvyymp4j2c6c5npfjseyjpdu 0.00015260 BTC p2tr U
- bc1pyr9x8f7z5t9cxykfzzx66y2xc3davshzmd3xmf9dcxdpkg4tjuusschhpq 0.01061148 BTC p2tr U
Size: 236
Vsize: 153
Fee: 1530
Confirmations: None
Block: None

Raw Signed Transaction: 02000000000101d2dd566a9e981a28798a1adc40fc541e93f98a65c79007dc99380a40ee23b94a7d00000000ffffffff029c3b00000000000022512027c66cb5bad28febfdf97bde021707d70abea10a7e88c21361ac958d62930a651c3110000000000022512020ca63a7c2a2cb8312c9108dad1146c45bd642e2db626da4adc19a1b22ab973902473044022019d43d372c8d6967f377f76d20a24d31fb3cb046a5640e9a02197afa526738dd02201afdc3e421665b35397ef2adf40908aeb3031569e49aab367285a9015effbd1f0121023f5bdab1fb426681f1a020998ffc69c844f380fe6e0d67b73e7fc9bc3291018b00000000

Everything seems ok when running the script and it even shows Verified as True but when I try to send it through bitcoin-cli I get a “non-mandatory-script-verify-flag (Witness program hash mismatch)” error.

I think I’m making a mistake signing my inputs but I’m not sure how, I checked the private key multiple times and it does match the address that currently holds the UTXO.

Can anyone advise what to do?



Source link

Related articles

Coinbase Expands USDC Loans to UK After Strong US Demand – Bitcoin News

Coinbase Expands USDC Loans to UK After Strong US Demand – Bitcoin News

April 20, 2026

Binance Offers $10 USDC Voucher Welcome Bonus for 99Bitcoins Readers

April 20, 2026
Share76Tweet47

Related Posts

Coinbase Expands USDC Loans to UK After Strong US Demand – Bitcoin News

Coinbase Expands USDC Loans to UK After Strong US Demand – Bitcoin News

by Moussa
April 20, 2026
0

Key Takeaways: Coinbase expanded U.K. access to USDC loans backed by BTC, ETH, and cbETH. Morpho strengthens Coinbase’s on-chain lending...

Binance Offers $10 USDC Voucher Welcome Bonus for 99Bitcoins Readers

by Moussa
April 20, 2026
0

Binance is giving 99Bitcoin readers an exclusive offer: a $10 USDC voucher when they sign up using our dedicated referral...

Cardano Founder Warns XRP Investors, Is Ripple Doing Something Wrong?

Cardano Founder Warns XRP Investors, Is Ripple Doing Something Wrong?

by Moussa
April 20, 2026
0

Trusted Editorial content, reviewed by leading industry experts and seasoned editors. Ad Disclosure Cardano founder Charles Hoskinson has warned XRP...

XRP A Strong Buy Before 2027 Despite 27% Drop: Finance Firm

XRP A Strong Buy Before 2027 Despite 27% Drop: Finance Firm

by Moussa
April 20, 2026
0

They say journalists never truly clock out. But for Christian, that's not just a metaphor, it's a lifestyle. By day,...

Lydian Launches Visa Platinum Crypto Card To Enable Everyday Spending Of Digital Assets

Lydian Launches Visa Platinum Crypto Card To Enable Everyday Spending Of Digital Assets

by Moussa
April 20, 2026
0

Lydian has launched the Lydian Card, a co-branded Visa Platinum card issued by Rain that allows users to spend more...

Load More

youssufi.com

sephina.com

[vc_row full_width="stretch_row" parallax="content-moving" vc_row_background="" background_repeat="no-repeat" background_position="center center" footer_scheme="dark" css=".vc_custom_1517813231908{padding-top: 60px !important;padding-bottom: 30px !important;background-color: #191818 !important;background-position: center;background-repeat: no-repeat !important;background-size: cover !important;}" footer_widget_title_color="#fcbf46" footer_button_bg="#fcb11e"][vc_column width="1/4"]

We bring you the latest in Crypto News

[/vc_column][vc_column width="1/4"][vc_wp_categories]
[/vc_column][vc_column width="1/4"][vc_wp_tagcloud taxonomy="post_tag"][/vc_column][vc_column width="1/4"]

Newsletter

[vc_raw_html]JTNDcCUzRSUzQ2RpdiUyMGNsYXN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0eXBlJTNEJTIyY2hlY2tib3glMjIlMjBuYW1lJTNEJTIybnklMjIlMjByZXF1aXJlZCUyMGNsYXNzJTNEJTIydG5wLXByaXZhY3klMjIlM0UlQzIlQTBCeSUyMGNvbnRpbnVpbmclMkMlMjB5b3UlMjBhY2NlcHQlMjB0aGUlMjBwcml2YWN5JTIwcG9saWN5JTNDJTJGbGFiZWwlM0UlM0MlMkZkaXYlM0UlM0NkaXYlMjBjbGFzcyUzRCUyMnRucC1maWVsZCUyMHRucC1maWVsZC1idXR0b24lMjIlM0UlM0NpbnB1dCUyMGNsYXNzJTNEJTIydG5wLXN1Ym1pdCUyMiUyMHR5cGUlM0QlMjJzdWJtaXQlMjIlMjB2YWx1ZSUzRCUyMlN1YnNjcmliZSUyMiUyMCUzRSUwQSUzQyUyRmRpdiUzRSUwQSUzQyUyRmZvcm0lM0UlMEElM0MlMkZkaXYlM0UlM0NiciUyRiUzRSUzQyUyRnAlM0U=[/vc_raw_html][/vc_column][/vc_row]
No Result
View All Result
  • Contact Us
  • Homepages
  • Business
  • Guide

© 2024 APPROX FOUNDATION - The Crypto Currency News