Skip to content

Commit d399266

Browse files
committed
psbt: Actually use SIGHASH_DEFAULT
Make the behavior align with the help text by actually using SIGHASH_DEFAULT as the default sighash for signing PSBTs.
1 parent eb9a1a2 commit d399266

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/core_read.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strN
248248

249249
int ParseSighashString(const UniValue& sighash)
250250
{
251-
int hash_type = SIGHASH_ALL;
251+
int hash_type = SIGHASH_DEFAULT;
252252
if (!sighash.isNull()) {
253253
static std::map<std::string, int> map_sighash_values = {
254254
{std::string("DEFAULT"), int(SIGHASH_DEFAULT)},

src/wallet/scriptpubkeyman.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class ScriptPubKeyMan
236236
/** Sign a message with the given script */
237237
virtual SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const { return SigningResult::SIGNING_FAILED; };
238238
/** Adds script and derivation path information to a PSBT, and optionally signs it. */
239-
virtual TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const { return TransactionError::INVALID_PSBT; }
239+
virtual TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const { return TransactionError::INVALID_PSBT; }
240240

241241
virtual uint256 GetID() const { return uint256(); }
242242

@@ -400,7 +400,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
400400

401401
bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const override;
402402
SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
403-
TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
403+
TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
404404

405405
uint256 GetID() const override;
406406

@@ -609,7 +609,7 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
609609

610610
bool SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const override;
611611
SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const override;
612-
TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
612+
TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = SIGHASH_DEFAULT, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
613613

614614
uint256 GetID() const override;
615615

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
561561
*/
562562
TransactionError FillPSBT(PartiallySignedTransaction& psbtx,
563563
bool& complete,
564-
int sighash_type = 1 /* SIGHASH_ALL */,
564+
int sighash_type = SIGHASH_DEFAULT,
565565
bool sign = true,
566566
bool bip32derivs = true,
567567
size_t* n_signed = nullptr,

test/functional/rpc_psbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def run_test(self):
457457
wrpc = self.nodes[2].get_wallet_rpc("wallet{}".format(i))
458458
for key in signer['privkeys']:
459459
wrpc.importprivkey(key)
460-
signed_tx = wrpc.walletprocesspsbt(signer['psbt'])['psbt']
460+
signed_tx = wrpc.walletprocesspsbt(signer['psbt'], True, "ALL")['psbt']
461461
assert_equal(signed_tx, signer['result'])
462462

463463
# Combiner test

0 commit comments

Comments
 (0)