Merge wallet_avoid_newerchange

This commit is contained in:
Luke Dashjr 2024-08-01 00:06:00 +00:00
commit 13f9c5d677
3 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,7 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc
{
LOCK2(wallet->cs_wallet, ::cs_main);
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
wallet->m_default_address_type = OutputType::BECH32M;
}
{
LOCK(wallet->cs_wallet);

View File

@ -2285,7 +2285,7 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
}
const bool has_bech32m_spkman(GetScriptPubKeyMan(OutputType::BECH32M, /*internal=*/true));
if (has_bech32m_spkman && any_tr) {
if (has_bech32m_spkman && any_tr && m_default_address_type == OutputType::BECH32M) {
// Currently tr is the only type supported by the BECH32M spkman
return OutputType::BECH32M;
}
@ -2305,6 +2305,16 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
// Currently pkh is the only type supported by the LEGACY spkman
return OutputType::LEGACY;
}
if (!GetScriptPubKeyMan(m_default_address_type, /*internal=*/true)) {
// Default type not available, so look for anything else to fallback to
// NOTE: Sane behaviour assumes OUTPUT_TYPES is sorted oldest to newest
for (const auto& ot : OUTPUT_TYPES) {
if (GetScriptPubKeyMan(ot, /*internal=*/true)) {
return ot;
}
}
}
return m_default_address_type;
if (has_bech32m_spkman) {
return OutputType::BECH32M;

View File

@ -194,6 +194,8 @@ class WalletTaprootTest(BitcoinTestFramework):
self.num_nodes = 2
self.setup_clean_chain = True
self.extra_args = [['-keypool=100'], ['-keypool=100']]
for ea in self.extra_args:
ea.append('-addresstype=bech32m')
self.supports_cli = False
def skip_test_if_missing_module(self):