I am attempting to observe the under transaction instance by magic eden and lengthen it to help a number of patrons and vendor (in purple). Nonetheless I’m having difficulties once I add a couple of signature from one other social gathering (with one vendor it broadcasts okay). The transaction builds and indicators wonderful however when I attempt to broadcast it to the community it leads to the error mandatory-script-verify-flag-failed (Signature have to be zero for failed CHECK(MULTI)SIG operation)
. Utilizing native segwit addresses for this (no-tr).
What am I lacking or doing fallacious?
Utilizing the bitcoinjs library here’s what I’ve up to now (solely the purple):
Vendor signing:
let psbt = new bitcoin.Psbt({ community });
const [ordinalUtxoTxId, ordinalUtxoVout] = ordinalOutput.cut up(":");
const tx = bitcoin.Transaction.fromHex(await getTxHexById(ordinalUtxoTxId));
attempt {
tx.setWitness(parseInt(ordinalUtxoVout), []);
} catch {}
const enter =
bitcoin.Transaction.SIGHASH_ANYONECANPAY,
;
psbt.addInput(enter);
psbt.addOutput({
tackle: paymentAddress,
worth: worth,
});
Purchaser Signing (ignoring padding inputs and outputs):
// Add inscriptions inputs and outputs
for (const signedPsbt of sellerSignedPsbts) {
// Add inscription output
psbt.addOutput({
tackle: receiverAddress,
worth: signedPsbt.information.inputs[0].witnessUtxo.worth,
});
// Add payer signed enter
psbt.addInput({
...signedPsbt.information.globalMap.unsignedTx.tx.ins[0],
// ...signedPsbt.information.inputs[0],
witnessUtxo: signedPsbt.information.inputs[0].witnessUtxo,
nonWitnessUtxo: signedPsbt.information.inputs[0].nonWitnessUtxo,
// finalScriptWitness: signedPsbt.information.inputs[0].finalScriptWitness,
});
enter++;
}
// Add vendor cost outputs for payee
for (const signedPsbt of sellerSignedPsbts) {
// Add payer output
psbt.addOutput({
...signedPsbt.information.globalMap.unsignedTx.tx.outs[0],
});
}
Merge vendor and purchaser signed psbts:
const buyerSignedPsbt = bitcoin.Psbt.fromBase64(signedBuyingPSBTBase64);
for (let index = 0; index < signedListingsPSBTBase64.size; index++) {
const sellerSignedPsbt = bitcoin.Psbt.fromBase64(signedListingsPSBTBase64[index]);
buyerSignedPsbt.information.globalMap.unsignedTx.tx.ins[BUYING_PSBT_SELLER_SIGNATURE_INDEX + index] = sellerSignedPsbt.information.globalMap.unsignedTx.tx.ins[0];
buyerSignedPsbt.information.inputs[BUYING_PSBT_SELLER_SIGNATURE_INDEX + index] = sellerSignedPsbt.information.inputs[0];
}
// broadcast buyerSignedPsbt