@@ -447,6 +447,34 @@ void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
447
447
} // msgBox.exec()
448
448
}
449
449
450
+ bool SendCoinsDialog::signWithExternalSigner (PartiallySignedTransaction& psbtx, CMutableTransaction& mtx, bool & complete) {
451
+ TransactionError err;
452
+ try {
453
+ err = model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ true , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete);
454
+ } catch (const std::runtime_error& e) {
455
+ QMessageBox::critical (nullptr , tr (" Sign failed" ), e.what ());
456
+ return false ;
457
+ }
458
+ if (err == TransactionError::EXTERNAL_SIGNER_NOT_FOUND) {
459
+ // : "External signer" means using devices such as hardware wallets.
460
+ QMessageBox::critical (nullptr , tr (" External signer not found" ), " External signer not found" );
461
+ return false ;
462
+ }
463
+ if (err == TransactionError::EXTERNAL_SIGNER_FAILED) {
464
+ // : "External signer" means using devices such as hardware wallets.
465
+ QMessageBox::critical (nullptr , tr (" External signer failure" ), " External signer failure" );
466
+ return false ;
467
+ }
468
+ if (err != TransactionError::OK) {
469
+ tfm::format (std::cerr, " Failed to sign PSBT" );
470
+ processSendCoinsReturn (WalletModel::TransactionCreationFailed);
471
+ return false ;
472
+ }
473
+ // fillPSBT does not always properly finalize
474
+ complete = FinalizeAndExtractPSBT (psbtx, mtx);
475
+ return true ;
476
+ }
477
+
450
478
void SendCoinsDialog::sendButtonClicked ([[maybe_unused]] bool checked)
451
479
{
452
480
if (!model || !model->getOptionsModel ())
@@ -479,33 +507,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
479
507
assert (!complete);
480
508
assert (err == TransactionError::OK);
481
509
if (model->wallet ().hasExternalSigner ()) {
482
- try {
483
- err = model->wallet ().fillPSBT (SIGHASH_ALL, true /* sign */ , true /* bip32derivs */ , nullptr , psbtx, complete);
484
- } catch (const std::runtime_error& e) {
485
- QMessageBox::critical (nullptr , tr (" Sign failed" ), e.what ());
486
- send_failure = true ;
487
- return ;
488
- }
489
- if (err == TransactionError::EXTERNAL_SIGNER_NOT_FOUND) {
490
- // : "External signer" means using devices such as hardware wallets.
491
- QMessageBox::critical (nullptr , tr (" External signer not found" ), " External signer not found" );
492
- send_failure = true ;
493
- return ;
494
- }
495
- if (err == TransactionError::EXTERNAL_SIGNER_FAILED) {
496
- // : "External signer" means using devices such as hardware wallets.
497
- QMessageBox::critical (nullptr , tr (" External signer failure" ), " External signer failure" );
498
- send_failure = true ;
499
- return ;
500
- }
501
- if (err != TransactionError::OK) {
502
- tfm::format (std::cerr, " Failed to sign PSBT" );
503
- processSendCoinsReturn (WalletModel::TransactionCreationFailed);
504
- send_failure = true ;
505
- return ;
506
- }
507
- // fillPSBT does not always properly finalize
508
- complete = FinalizeAndExtractPSBT (psbtx, mtx);
510
+ send_failure = !signWithExternalSigner (psbtx, mtx, complete);
509
511
}
510
512
511
513
// Broadcast transaction if complete (even with an external signer this
0 commit comments