Skip to content

Commit 1dca9dc

Browse files
committed
refactor: Change createWallet, fillPSBT argument order
Move output arguments after input arguments for consistency with other methods, and to work more easily with IPC framework in #10102
1 parent 96dfe5c commit 1dca9dc

File tree

7 files changed

+18
-19
lines changed

7 files changed

+18
-19
lines changed

src/interfaces/node.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,11 @@ class NodeImpl : public Node
262262
{
263263
return MakeWallet(LoadWallet(*m_context.chain, name, error, warnings));
264264
}
265-
WalletCreationStatus createWallet(const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, std::string& error, std::vector<std::string>& warnings, std::unique_ptr<Wallet>& result) override
265+
std::unique_ptr<Wallet> createWallet(const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, std::string& error, std::vector<std::string>& warnings, WalletCreationStatus& status) override
266266
{
267267
std::shared_ptr<CWallet> wallet;
268-
WalletCreationStatus status = CreateWallet(*m_context.chain, passphrase, wallet_creation_flags, name, error, warnings, wallet);
269-
result = MakeWallet(wallet);
270-
return status;
268+
status = CreateWallet(*m_context.chain, passphrase, wallet_creation_flags, name, error, warnings, wallet);
269+
return MakeWallet(wallet);
271270
}
272271
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override
273272
{

src/interfaces/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Node
204204
virtual std::unique_ptr<Wallet> loadWallet(const std::string& name, std::string& error, std::vector<std::string>& warnings) = 0;
205205

206206
//! Create a wallet from file
207-
virtual WalletCreationStatus createWallet(const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, std::string& error, std::vector<std::string>& warnings, std::unique_ptr<Wallet>& result) = 0;
207+
virtual std::unique_ptr<Wallet> createWallet(const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, std::string& error, std::vector<std::string>& warnings, WalletCreationStatus& status) = 0;
208208

209209
//! Register handler for init messages.
210210
using InitMessageFn = std::function<void(const std::string& message)>;

src/interfaces/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ class WalletImpl : public Wallet
352352
}
353353
return {};
354354
}
355-
TransactionError fillPSBT(PartiallySignedTransaction& psbtx,
356-
bool& complete,
357-
int sighash_type = 1 /* SIGHASH_ALL */,
358-
bool sign = true,
359-
bool bip32derivs = false) const override
355+
TransactionError fillPSBT(int sighash_type,
356+
bool sign,
357+
bool bip32derivs,
358+
PartiallySignedTransaction& psbtx,
359+
bool& complete) override
360360
{
361361
return m_wallet->FillPSBT(psbtx, complete, sighash_type, sign, bip32derivs);
362362
}

src/interfaces/wallet.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ class Wallet
193193
int& num_blocks) = 0;
194194

195195
//! Fill PSBT.
196-
virtual TransactionError fillPSBT(PartiallySignedTransaction& psbtx,
197-
bool& complete,
198-
int sighash_type = 1 /* SIGHASH_ALL */,
199-
bool sign = true,
200-
bool bip32derivs = false) const = 0;
196+
virtual TransactionError fillPSBT(int sighash_type,
197+
bool sign,
198+
bool bip32derivs,
199+
PartiallySignedTransaction& psbtx,
200+
bool& complete) = 0;
201201

202202
//! Get balances.
203203
virtual WalletBalances getBalances() = 0;

src/qt/sendcoinsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void SendCoinsDialog::on_sendButton_clicked()
391391
CMutableTransaction mtx = CMutableTransaction{*(currentTransaction.getWtx())};
392392
PartiallySignedTransaction psbtx(mtx);
393393
bool complete = false;
394-
const TransactionError err = model->wallet().fillPSBT(psbtx, complete, SIGHASH_ALL, false /* sign */, true /* bip32derivs */);
394+
const TransactionError err = model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete);
395395
assert(!complete);
396396
assert(err == TransactionError::OK);
397397
// Serialize the PSBT

src/qt/walletcontroller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ void CreateWalletActivity::createWallet()
218218
}
219219

220220
QTimer::singleShot(500, worker(), [this, name, flags] {
221-
std::unique_ptr<interfaces::Wallet> wallet;
222-
WalletCreationStatus status = node().createWallet(m_passphrase, flags, name, m_error_message, m_warning_message, wallet);
221+
WalletCreationStatus status;
222+
std::unique_ptr<interfaces::Wallet> wallet = node().createWallet(m_passphrase, flags, name, m_error_message, m_warning_message, status);
223223

224224
if (status == WalletCreationStatus::SUCCESS) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
225225

src/qt/walletmodel.cpp

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

0 commit comments

Comments
 (0)