Skip to content

Commit

Permalink
refactor: Change createWallet, fillPSBT argument order
Browse files Browse the repository at this point in the history
Summary:
Move output arguments after input arguments for consistency with other methods,
and to work more easily with IPC framework in #10102

Backport of Core [[bitcoin/bitcoin#18278 | PR18278]] part [5/6] : bitcoin/bitcoin@1dca9dc

Depends on D8022

The Qt part of PSBT has not been ported so it is absent from this patch. This shouldn't be a problem, because it is a compilation error and trivial to fix, so it can be don then.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D8023
  • Loading branch information
ryanofsky authored and deadalnix committed Oct 21, 2020
1 parent ba43817 commit 2412801
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
13 changes: 6 additions & 7 deletions src/interfaces/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,16 @@ namespace {
return MakeWallet(
LoadWallet(params, *m_context->chain, name, error, warnings));
}
WalletCreationStatus
std::unique_ptr<Wallet>
createWallet(const CChainParams &params, const SecureString &passphrase,
uint64_t wallet_creation_flags, const std::string &name,
bilingual_str &error, std::vector<bilingual_str> &warnings,
std::unique_ptr<Wallet> &result) override {
WalletCreationStatus &status) override {
std::shared_ptr<CWallet> wallet;
WalletCreationStatus status = CreateWallet(
params, *m_context->chain, passphrase, wallet_creation_flags,
name, error, warnings, wallet);
result = MakeWallet(wallet);
return status;
status = CreateWallet(params, *m_context->chain, passphrase,
wallet_creation_flags, name, error, warnings,
wallet);
return MakeWallet(wallet);
}
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override {
return MakeHandler(::uiInterface.InitMessage_connect(fn));
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ class Node {
std::vector<bilingual_str> &warnings) const = 0;

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

//! Register handler for init messages.
using InitMessageFn = std::function<void(const std::string &message)>;
Expand Down
9 changes: 4 additions & 5 deletions src/interfaces/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,10 @@ namespace {
}
return {};
}
TransactionError
fillPSBT(PartiallySignedTransaction &psbtx, bool &complete,
SigHashType sighash_type =
SigHashType().withForkId() /* SIGHASH_ALL|FORKID */,
bool sign = true, bool bip32derivs = false) override {
TransactionError fillPSBT(SigHashType sighash_type, bool sign,
bool bip32derivs,
PartiallySignedTransaction &psbtx,
bool &complete) override {
return FillPSBT(m_wallet.get(), psbtx, complete, sighash_type, sign,
bip32derivs);
}
Expand Down
9 changes: 4 additions & 5 deletions src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,10 @@ class Wallet {
bool &in_mempool, int &num_blocks) = 0;

//! Fill PSBT.
virtual TransactionError
fillPSBT(PartiallySignedTransaction &psbtx, bool &complete,
SigHashType sighash_type =
SigHashType().withForkId() /* SIGHASH_ALL|FORKID */,
bool sign = true, bool bip32derivs = false) = 0;
virtual TransactionError fillPSBT(SigHashType sighash_type, bool sign,
bool bip32derivs,
PartiallySignedTransaction &psbtx,
bool &complete) = 0;

//! Get balances.
virtual WalletBalances getBalances() = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ void SendCoinsDialog::on_sendButton_clicked() {
PartiallySignedTransaction psbtx(mtx);
bool complete = false;
const TransactionError err = model->wallet().fillPSBT(
psbtx, complete, SigHashType().withForkId(), false /* sign */,
true /* bip32derivs */);
SigHashType().withForkId(), false /* sign */,
true /* bip32derivs */, psbtx, complete);
assert(!complete);
assert(err == TransactionError::OK);
// Serialize the PSBT
Expand Down
8 changes: 4 additions & 4 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ void CreateWalletActivity::createWallet() {
}

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

if (status == WalletCreationStatus::SUCCESS) {
m_wallet_model =
Expand Down

0 comments on commit 2412801

Please sign in to comment.