Skip to content

Commit

Permalink
Get all the way to ReceiverTxInNotFinalized
Browse files Browse the repository at this point in the history
With main / isolate separation so that signing can happen in the main thread
  • Loading branch information
DanGould committed Dec 20, 2024
1 parent 7ac0f00 commit 21c9bda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions lib/_pkg/payjoin/manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -577,6 +572,7 @@ Future<void> _isolateReceiver(List<dynamic> args) async {
{'psbt': psbt},
sendPort,
);
print('process_psbt result: $result');
return result as String;
},
maxFeeRateSatPerVb: BigInt.from(10000),
Expand Down Expand Up @@ -622,7 +618,10 @@ Future<void> _isolateReceiver(List<dynamic> 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();
Expand Down
2 changes: 1 addition & 1 deletion lib/_pkg/wallet/bdk/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ class BDKTransactions {
psbt: psbtStruct,
signOptions: const bdk.SignOptions(
// multiSig: false,
trustWitnessUtxo: false,
trustWitnessUtxo: true,
allowAllSighashes: false,
removePartialSigs: true,
tryFinalize: true,
Expand Down

0 comments on commit 21c9bda

Please sign in to comment.