From 21c9bdac72ef20eab3e7ca001d7229c69713c102 Mon Sep 17 00:00:00 2001 From: DanGould Date: Wed, 18 Dec 2024 02:41:19 -0500 Subject: [PATCH] Get all the way to ReceiverTxInNotFinalized With main / isolate separation so that signing can happen in the main thread --- lib/_pkg/payjoin/manager.dart | 23 +++++++++++------------ lib/_pkg/wallet/bdk/transaction.dart | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/_pkg/payjoin/manager.dart b/lib/_pkg/payjoin/manager.dart index 8350a57b..49497c76 100644 --- a/lib/_pkg/payjoin/manager.dart +++ b/lib/_pkg/payjoin/manager.dart @@ -162,21 +162,16 @@ class PayjoinManager { case 'process_psbt': try { final psbt = message['psbt'] as String; - final (result, err) = await _walletTx.signPsbt( - psbt: psbt, - wallet: wallet, - ); - if (err != null) { - completer.complete(err); - return; - } - final signedPsbt = result!.$2; + print('process_psbt: $psbt'); + final signedPsbt = + await processPsbt(psbt: psbt, wallet: wallet); + print('signedPsbt: $signedPsbt'); mainToIsolateSendPort?.send({ - 'type': 'signed_psbt', 'requestId': message['requestId'], - 'psbt': signedPsbt, + 'result': signedPsbt, }); } catch (e) { + print('err: $e'); rethrow; } break; @@ -577,6 +572,7 @@ Future _isolateReceiver(List args) async { {'psbt': psbt}, sendPort, ); + print('process_psbt result: $result'); return result as String; }, maxFeeRateSatPerVb: BigInt.from(10000), @@ -622,7 +618,10 @@ Future _isolateReceiver(List args) async { } } final payjoin_proposal = await processPayjoinProposal( - unchecked_proposal!, isolateTomainSendPort, isolateReceivePort); + unchecked_proposal!, + isolateTomainSendPort, + isolateReceivePort, + ); print('payjoin proposal: $payjoin_proposal'); try { final (postReq, ohttpCtx) = await payjoin_proposal.extractV2Req(); diff --git a/lib/_pkg/wallet/bdk/transaction.dart b/lib/_pkg/wallet/bdk/transaction.dart index 9b5c56b4..d724822b 100644 --- a/lib/_pkg/wallet/bdk/transaction.dart +++ b/lib/_pkg/wallet/bdk/transaction.dart @@ -600,7 +600,7 @@ class BDKTransactions { psbt: psbtStruct, signOptions: const bdk.SignOptions( // multiSig: false, - trustWitnessUtxo: false, + trustWitnessUtxo: true, allowAllSighashes: false, removePartialSigs: true, tryFinalize: true,