mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Merge bitcoin/bitcoin#22214: refactor: Rearrange fillPSBT arguments
f47e802839
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: ACKf47e802839
theStack: Code-review ACKf47e802839
Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
This commit is contained in:
commit
9795e8ec8c
5 changed files with 10 additions and 10 deletions
|
@ -198,9 +198,9 @@ public:
|
||||||
virtual TransactionError fillPSBT(int sighash_type,
|
virtual TransactionError fillPSBT(int sighash_type,
|
||||||
bool sign,
|
bool sign,
|
||||||
bool bip32derivs,
|
bool bip32derivs,
|
||||||
|
size_t* n_signed,
|
||||||
PartiallySignedTransaction& psbtx,
|
PartiallySignedTransaction& psbtx,
|
||||||
bool& complete,
|
bool& complete) = 0;
|
||||||
size_t* n_signed) = 0;
|
|
||||||
|
|
||||||
//! Get balances.
|
//! Get balances.
|
||||||
virtual WalletBalances getBalances() = 0;
|
virtual WalletBalances getBalances() = 0;
|
||||||
|
|
|
@ -50,7 +50,7 @@ void PSBTOperationsDialog::openWithPSBT(PartiallySignedTransaction psbtx)
|
||||||
bool complete;
|
bool complete;
|
||||||
size_t n_could_sign;
|
size_t n_could_sign;
|
||||||
FinalizePSBT(psbtx); // Make sure all existing signatures are fully combined before checking for completeness.
|
FinalizePSBT(psbtx); // Make sure all existing signatures are fully combined before checking for completeness.
|
||||||
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, m_transaction_data, complete, &n_could_sign);
|
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, &n_could_sign, m_transaction_data, complete);
|
||||||
if (err != TransactionError::OK) {
|
if (err != TransactionError::OK) {
|
||||||
showStatus(tr("Failed to load transaction: %1")
|
showStatus(tr("Failed to load transaction: %1")
|
||||||
.arg(QString::fromStdString(TransactionErrorString(err).translated)), StatusLevel::ERR);
|
.arg(QString::fromStdString(TransactionErrorString(err).translated)), StatusLevel::ERR);
|
||||||
|
@ -67,7 +67,7 @@ void PSBTOperationsDialog::signTransaction()
|
||||||
{
|
{
|
||||||
bool complete;
|
bool complete;
|
||||||
size_t n_signed;
|
size_t n_signed;
|
||||||
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, m_transaction_data, complete, &n_signed);
|
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, &n_signed, m_transaction_data, complete);
|
||||||
|
|
||||||
if (err != TransactionError::OK) {
|
if (err != TransactionError::OK) {
|
||||||
showStatus(tr("Failed to sign transaction: %1")
|
showStatus(tr("Failed to sign transaction: %1")
|
||||||
|
@ -226,7 +226,7 @@ void PSBTOperationsDialog::showStatus(const QString &msg, StatusLevel level) {
|
||||||
size_t PSBTOperationsDialog::couldSignInputs(const PartiallySignedTransaction &psbtx) {
|
size_t PSBTOperationsDialog::couldSignInputs(const PartiallySignedTransaction &psbtx) {
|
||||||
size_t n_signed;
|
size_t n_signed;
|
||||||
bool complete;
|
bool complete;
|
||||||
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, false /* bip32derivs */, m_transaction_data, complete, &n_signed);
|
TransactionError err = m_wallet_model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, false /* bip32derivs */, &n_signed, m_transaction_data, complete);
|
||||||
|
|
||||||
if (err != TransactionError::OK) {
|
if (err != TransactionError::OK) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -414,12 +414,12 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
// Always fill without signing first. This prevents an external signer
|
// Always fill without signing first. This prevents an external signer
|
||||||
// from being called prematurely and is not expensive.
|
// from being called prematurely and is not expensive.
|
||||||
TransactionError err = model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
|
TransactionError err = model->wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
|
||||||
assert(!complete);
|
assert(!complete);
|
||||||
assert(err == TransactionError::OK);
|
assert(err == TransactionError::OK);
|
||||||
if (model->wallet().hasExternalSigner()) {
|
if (model->wallet().hasExternalSigner()) {
|
||||||
try {
|
try {
|
||||||
err = model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
|
err = model->wallet().fillPSBT(SIGHASH_ALL, true /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
QMessageBox::critical(nullptr, tr("Sign failed"), e.what());
|
QMessageBox::critical(nullptr, tr("Sign failed"), e.what());
|
||||||
send_failure = true;
|
send_failure = true;
|
||||||
|
|
|
@ -525,7 +525,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
|
||||||
if (create_psbt) {
|
if (create_psbt) {
|
||||||
PartiallySignedTransaction psbtx(mtx);
|
PartiallySignedTransaction psbtx(mtx);
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, psbtx, complete, nullptr);
|
const TransactionError err = wallet().fillPSBT(SIGHASH_ALL, false /* sign */, true /* bip32derivs */, nullptr, psbtx, complete);
|
||||||
if (err != TransactionError::OK || complete) {
|
if (err != TransactionError::OK || complete) {
|
||||||
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
|
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction."));
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -349,9 +349,9 @@ public:
|
||||||
TransactionError fillPSBT(int sighash_type,
|
TransactionError fillPSBT(int sighash_type,
|
||||||
bool sign,
|
bool sign,
|
||||||
bool bip32derivs,
|
bool bip32derivs,
|
||||||
|
size_t* n_signed,
|
||||||
PartiallySignedTransaction& psbtx,
|
PartiallySignedTransaction& psbtx,
|
||||||
bool& complete,
|
bool& complete) override
|
||||||
size_t* n_signed) override
|
|
||||||
{
|
{
|
||||||
return m_wallet->FillPSBT(psbtx, complete, sighash_type, sign, bip32derivs, n_signed);
|
return m_wallet->FillPSBT(psbtx, complete, sighash_type, sign, bip32derivs, n_signed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue