@kumulynja mentioned to me that
[in] the last step of broadcasting the payjoin transaction I get the following error:
BdkError.electrum(field0: Electrum server error: "sendrawtransaction RPC error -26: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)")
The proposal psbt is finalized when signing with the sender before broadcasting, and I think I am using the same signing options as in the current version, so not sure what to change there.
Turned out @kumulynja was passing empty lists to the psbt::Input's redeemScript and witnessScript fields, but should have been leaving them None to spend his P2WPKH Input. See the commented code below:

I believe I recall @konstantinullrich having a similar problem in implementation.
I wonder if AddressType-specific constructors (e.g. InputPair::new_p2tr, InputPair::new_p2wpkh etc.) would have prevented this implementation error. It was tricky to hunt down what the problem even was since it only failed script verification.
To be explicit, I think their flutter (dart) implementation:
Future<InputPair> _inputPairFromUtxo(bdk.LocalUtxo utxo, bool isTestnet) async {
final psbtin = PsbtInput(
witnessUtxo: TxOut(
value: utxo.txout.value,
scriptPubkey: utxo.txout.scriptPubkey.bytes,
),
);
final txin = TxIn(
previousOutput:
OutPoint(txid: utxo.outpoint.txid, vout: utxo.outpoint.vout),
scriptSig: await Script.newInstance(rawOutputScript: []),
sequence: 0xFFFFFFFF,
witness: [],
);
return InputPair.newInstance(txin, psbtin);
}
May prevent misuse if an imagined InputPair constructor were instead applied as
InputPair _inputPairFromUtxo(bdk.LocalUtxo utxo, bool isTestnet) {
return InputPair.newP2wpkh(witnessUtxo: utxo.txout, previousOutput: utxo.outpoint);
}
and provided the other fields as defaults (perhaps with optional sequence), or further specified the necessary parameters to create a p2wpkh InputPair.
@kumulynja mentioned to me that
Turned out @kumulynja was passing empty lists to the
psbt::Input'sredeemScriptandwitnessScriptfields, but should have been leaving themNoneto spend hisP2WPKHInput. See the commented code below:I believe I recall @konstantinullrich having a similar problem in implementation.
I wonder if AddressType-specific constructors (e.g.
InputPair::new_p2tr,InputPair::new_p2wpkhetc.) would have prevented this implementation error. It was tricky to hunt down what the problem even was since it only failed script verification.To be explicit, I think their flutter (dart) implementation:
May prevent misuse if an imagined
InputPairconstructor were instead applied asand provided the other fields as defaults (perhaps with optional sequence), or further specified the necessary parameters to create a p2wpkh InputPair.