3737#include < QSettings>
3838#include < QTextDocument>
3939
40+ using common::PSBTError;
4041using wallet::CCoinControl;
4142using wallet::DEFAULT_PAY_TX_FEE;
4243
@@ -442,26 +443,26 @@ void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
442443}
443444
444445bool SendCoinsDialog::signWithExternalSigner (PartiallySignedTransaction& psbtx, CMutableTransaction& mtx, bool & complete) {
445- TransactionError err;
446+ std::optional<PSBTError> err;
446447 try {
447448 err = model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ true , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete);
448449 } catch (const std::runtime_error& e) {
449450 QMessageBox::critical (nullptr , tr (" Sign failed" ), e.what ());
450451 return false ;
451452 }
452- if (err == TransactionError ::EXTERNAL_SIGNER_NOT_FOUND) {
453+ if (err == PSBTError ::EXTERNAL_SIGNER_NOT_FOUND) {
453454 // : "External signer" means using devices such as hardware wallets.
454455 const QString msg = tr (" External signer not found" );
455456 QMessageBox::critical (nullptr , msg, msg);
456457 return false ;
457458 }
458- if (err == TransactionError ::EXTERNAL_SIGNER_FAILED) {
459+ if (err == PSBTError ::EXTERNAL_SIGNER_FAILED) {
459460 // : "External signer" means using devices such as hardware wallets.
460461 const QString msg = tr (" External signer failure" );
461462 QMessageBox::critical (nullptr , msg, msg);
462463 return false ;
463464 }
464- if (err != TransactionError::OK ) {
465+ if (err) {
465466 tfm::format (std::cerr, " Failed to sign PSBT" );
466467 processSendCoinsReturn (WalletModel::TransactionCreationFailed);
467468 return false ;
@@ -501,9 +502,9 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
501502 PartiallySignedTransaction psbtx (mtx);
502503 bool complete = false ;
503504 // Fill without signing
504- TransactionError err = model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ false , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete);
505+ const auto err{ model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ false , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete)} ;
505506 assert (!complete);
506- assert (err == TransactionError::OK );
507+ assert (! err);
507508
508509 // Copy PSBT to clipboard and offer to save
509510 presentPSBT (psbtx);
@@ -517,9 +518,9 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
517518 bool complete = false ;
518519 // Always fill without signing first. This prevents an external signer
519520 // from being called prematurely and is not expensive.
520- TransactionError err = model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ false , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete);
521+ const auto err{ model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ false , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete)} ;
521522 assert (!complete);
522- assert (err == TransactionError::OK );
523+ assert (! err);
523524 send_failure = !signWithExternalSigner (psbtx, mtx, complete);
524525 // Don't broadcast when user rejects it on the device or there's a failure:
525526 broadcast = complete && !send_failure;
0 commit comments