I’m trying to add SegWit functionality to my app but am running into trouble building my transaction. I’ve read BIP143 so many times I virtually have it memorized, and I’ve followed it to the letter. But for whatever reason my TX is being rejected.
Here’s how my transaction is structured:
input #1 AF83F3F0EA5D11C3824C336250325D7597F891384282F73362AF0D7A70A94713, index=1, amount = 1000000
This is a P2WPKH input corresponding to address bc1qe9p5qmlqwhaxtmjkrdfp8lyswyww8ur5pzkg3c
input #2: E85B128C57AD00E7439D25E1ED1BA18E74886D45E45DEE7F4C196566946D0BC9, index=1, amount = 3571510
This is a standard P2PKH input
output #1: bc1q5ss6h56zsv56q3w2axwwv2v9zqgajtr5ud5llr, amount = 1071200
output #2: bc1qj2r7lu7g3tccv4zsg54c08ptgescaxt8u8tfvs, amount = 3471510
I’ve built my transaction according to the specifications presented in BIP143. Here’s the transaction in hex form:
Now, if you take that transaction and plug it into a deocder like the one here, you’ll see that everything is parsed properly. Everything looks good. Still, everyone rejects my transaction. For example:
Pushing through Blockchain.info or using the raw transaction pusher in Electrum yield the following error:
Validation Error: BitcoindException(super=com.neemre.btcdcli4j.core.BitcoindException: Error #-26: 64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation), code=-26)
Pushing through BlockCypher yields a different error:
af83f3f0ea5d11c3824c336250325d7597f891384282f73362af0d7a70a94713 at 1: Script was NOT verified successfully..
The errors are a bit cryptic but that second error seems to be pointing the finger at my first P2WPKH input. It says the script wasn’t verified. The thing is though, P2WPKH inputs don’t have a SigScript. By definition, the SigScript is supposed to be empty. So presumably it’s referring to my witness which, as you can see if you used the decoder, contains two items: a signature and a public key.
I swear I’ve checked that signature 100 times. It verifies. Perhaps what I’m signing (the sighash, also described in BIP143) was improperly constructed? But again, I’ve looked it over and I’m following the 10 step sighash generation procedure precisely.
which brings me back to the error generated by Electrum:
Error #-26: 64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation), code=-26)
I haven’t a clue was this means. The only reference to non-mandatory flags that I can find is here and code ’64’ seems to refer to a constant named SCRIPT_VERIFY_MINIMAL data. There’s also code “-26” in the error message. I haven’t a clue what that refers to.
I feel like this must be signature related somehow but like I said, the signature verifies just fine. I’ve made sure that the sig has a “low S value,” which has caused me some problems in the past. Not sure where else to look. I’m totally stumped.
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!