Closed sinanouri closed 3 years ago
isSegwit
logic is flawed. It contains "is the parent transaction a segwit transaction? (aka. does it have witnesses in the inputs)" but this has nothing to do "Is the OUTPUT I am using in this input a SEGWIT SCRIPT?"
mhx8a8NAn7jXjTvwGyYEAZ5GDiRGeskF38
is not an address for segwit, nor is it p2sh or p2wsh...
So therefore, to spend it you must use P2PKH and not P2SH-P2WPKH.
validateSignaturesOfAllInputs
passed with true because you essentially gave the Psbt false information; you said witnessUtxo.script
was the p2sh output. This is not true. Looking at the blockchain, the script is a p2pkh output. Since our library is not a full node, we have no way to tell if the data you input is true.
I am trying to spend segwit utxo from an address but i get
MANDATORY-SCRIPT-VERIFY-FLAG-FAILED
error while trying to broadcast. here is my code:when i am checking with psbt.validateSignaturesOfAllInputs () it returns true and the final signed transaction is:
02000000000101d27f34edb248cec78ba42b5effec92483dd64c9a1709ceb43b96666fc7773c4000000000171600141ab33ac298aab1a41a080cd809ddcaa463a99c6cffffffff0108070000000000001976a9140ddf88e6f1c54d83596ba4ffa362a0ec2473077988ac0248304502210086168d871aaa548843c75cdc9220dca1857520fc2d99d8db48d170f5558983bb0220505cb32ac4a1ff3ccb757ffa1271f9dbe10d3ce2097e2fa77454f5b2e65e14450121031327d6d2948bcbfd952bf06f095379d2328832575284fb957b5ab288a7f2965a00000000
when i decode it using https://testnet.smartbit.com.au/txs/decodetx i get:
but at the last step when trying to broadcast i get this error:
PUSH TRANSACTION ERROR: 16: MANDATORY-SCRIPT-VERIFY-FLAG-FAILED (SCRIPT FAILED AN OP_EQUALVERIFY OPERATION)
i could not find out which part i am doing wrong, would you please help me figure out the problem?