Skip to content

Commit 9795e8e

Browse files
committed
Merge bitcoin/bitcoin#22214: refactor: Rearrange fillPSBT arguments
f47e802 Rearrange fillPSBT arguments (Russell Yanofsky) Pull request description: Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list). --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR #10102. ACKs for top commit: achow101: ACK f47e802 theStack: Code-review ACK f47e802 Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
2 parents a55904a + f47e802 commit 9795e8e

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/interfaces/wallet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ class Wallet
198198
virtual TransactionError fillPSBT(int sighash_type,
199199
bool sign,
200200
bool bip32derivs,
201+
size_t* n_signed,
201202
PartiallySignedTransaction& psbtx,
202-
bool& complete,
203-
size_t* n_signed) = 0;
203+
bool& complete) = 0;
204204

205205
//! Get balances.
206206
virtual WalletBalances getBalances() = 0;

src/qt/psbtoperationsdialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void PSBTOperationsDialog::openWithPSBT(PartiallySignedTransaction psbtx)
5050
bool complete;
5151
size_t n_could_sign;
5252
FinalizePSBT(psbtx); // Make sure all existing signatures are fully combined before checking for completeness.
53-
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, m_transaction_data, complete, &n_could_sign);
53+
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, &n_could_sign, m_transaction_data, complete);
5454
if (err != TransactionError::OK) {
5555
showStatus(tr("Failed to load transaction: %1")
5656
.arg(QString::fromStdString(TransactionErrorString(err).translated)), StatusLevel::ERR);
@@ -67,7 +67,7 @@ void PSBTOperationsDialog::signTransaction()
6767
{
6868
bool complete;
6969
size_t n_signed;
70-
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, m_transaction_data, complete, &n_signed);
70+
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, &n_signed, m_transaction_data, complete);
7171

7272
if (err != TransactionError::OK) {
7373
showStatus(tr("Failed to sign transaction: %1")
@@ -226,7 +226,7 @@ void PSBTOperationsDialog::showStatus(const QString &msg, StatusLevel level) {
226226
size_t PSBTOperationsDialog::couldSignInputs(const PartiallySignedTransaction &psbtx) {
227227
size_t n_signed;
228228
bool complete;
229-
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, false /* bip32derivs */, m_transaction_data, complete, &n_signed);
229+
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, false /* bip32derivs */, &n_signed, m_transaction_data, complete);
230230

231231
if (err != TransactionError::OK) {
232232
return 0;

src/qt/sendcoinsdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,12 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
414414
bool complete = false;
415415
// Always fill without signing first. This prevents an external signer
416416
// from being called prematurely and is not expensive.
417-
TransactionError err = model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
417+
TransactionError err = model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
418418
assert(!complete);
419419
assert(err == TransactionError::OK);
420420
if (model->wallet().hasExternalSigner()) {
421421
try {
422-
err = model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
422+
err = model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
423423
} catch (const std::runtime_error& e) {
424424
QMessageBox::critical(nullptr, tr("Sign failed"), e.what());
425425
send_failure = true;

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
525525
if (create_psbt) {
526526
PartiallySignedTransaction psbtx(mtx);
527527
bool complete = false;
528-
const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
528+
const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
529529
if (err != TransactionError::OK || complete) {
530530
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
531531
return false;

src/wallet/interfaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ class WalletImpl : public Wallet
349349
TransactionError fillPSBT(int sighash_type,
350350
bool sign,
351351
bool bip32derivs,
352+
size_t* n_signed,
352353
PartiallySignedTransaction& psbtx,
353-
bool& complete,
354-
size_t* n_signed) override
354+
bool& complete) override
355355
{
356356
return m_wallet->FillPSBT(psbtx, complete, sighash_type, sign, bip32derivs, n_signed);
357357
}

0 commit comments

Comments
 (0)