37
37
#include < QSettings>
38
38
#include < QTextDocument>
39
39
40
+ using common::PSBTError;
40
41
using wallet::CCoinControl;
41
42
using wallet::DEFAULT_PAY_TX_FEE;
42
43
@@ -442,26 +443,26 @@ void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
442
443
}
443
444
444
445
bool SendCoinsDialog::signWithExternalSigner (PartiallySignedTransaction& psbtx, CMutableTransaction& mtx, bool & complete) {
445
- TransactionError err;
446
+ std::optional<PSBTError> err;
446
447
try {
447
448
err = model->wallet ().fillPSBT (SIGHASH_ALL, /* sign=*/ true , /* bip32derivs=*/ true , /* n_signed=*/ nullptr , psbtx, complete);
448
449
} catch (const std::runtime_error& e) {
449
450
QMessageBox::critical (nullptr , tr (" Sign failed" ), e.what ());
450
451
return false ;
451
452
}
452
- if (err == TransactionError ::EXTERNAL_SIGNER_NOT_FOUND) {
453
+ if (err == PSBTError ::EXTERNAL_SIGNER_NOT_FOUND) {
453
454
// : "External signer" means using devices such as hardware wallets.
454
455
const QString msg = tr (" External signer not found" );
455
456
QMessageBox::critical (nullptr , msg, msg);
456
457
return false ;
457
458
}
458
- if (err == TransactionError ::EXTERNAL_SIGNER_FAILED) {
459
+ if (err == PSBTError ::EXTERNAL_SIGNER_FAILED) {
459
460
// : "External signer" means using devices such as hardware wallets.
460
461
const QString msg = tr (" External signer failure" );
461
462
QMessageBox::critical (nullptr , msg, msg);
462
463
return false ;
463
464
}
464
- if (err != TransactionError::OK ) {
465
+ if (err) {
465
466
tfm::format (std::cerr, " Failed to sign PSBT" );
466
467
processSendCoinsReturn (WalletModel::TransactionCreationFailed);
467
468
return false ;
@@ -501,9 +502,9 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
501
502
PartiallySignedTransaction psbtx (mtx);
502
503
bool complete = false ;
503
504
// 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)} ;
505
506
assert (!complete);
506
- assert (err == TransactionError::OK );
507
+ assert (! err);
507
508
508
509
// Copy PSBT to clipboard and offer to save
509
510
presentPSBT (psbtx);
@@ -517,9 +518,9 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
517
518
bool complete = false ;
518
519
// Always fill without signing first. This prevents an external signer
519
520
// 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)} ;
521
522
assert (!complete);
522
- assert (err == TransactionError::OK );
523
+ assert (! err);
523
524
send_failure = !signWithExternalSigner (psbtx, mtx, complete);
524
525
// Don't broadcast when user rejects it on the device or there's a failure:
525
526
broadcast = complete && !send_failure;
0 commit comments