Skip to content

Commit 5962a67

Browse files
committed
Merge wallet_avoid_newerchange
2 parents 401f2f0 + 70dcdd7 commit 5962a67

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/wallet/test/util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc
2323
{
2424
LOCK2(wallet->cs_wallet, ::cs_main);
2525
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
26+
wallet->m_default_address_type = OutputType::BECH32M;
2627
}
2728
{
2829
LOCK(wallet->cs_wallet);

src/wallet/wallet.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
23502350
}
23512351

23522352
const bool has_bech32m_spkman(GetScriptPubKeyMan(OutputType::BECH32M, /*internal=*/true));
2353-
if (has_bech32m_spkman && any_tr) {
2353+
if (has_bech32m_spkman && any_tr && m_default_address_type == OutputType::BECH32M) {
23542354
// Currently tr is the only type supported by the BECH32M spkman
23552355
return OutputType::BECH32M;
23562356
}
@@ -2370,6 +2370,16 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
23702370
// Currently pkh is the only type supported by the LEGACY spkman
23712371
return OutputType::LEGACY;
23722372
}
2373+
if (!GetScriptPubKeyMan(m_default_address_type, /*internal=*/true)) {
2374+
// Default type not available, so look for anything else to fallback to
2375+
// NOTE: Sane behaviour assumes OUTPUT_TYPES is sorted oldest to newest
2376+
for (const auto& ot : OUTPUT_TYPES) {
2377+
if (GetScriptPubKeyMan(ot, /*internal=*/true)) {
2378+
return ot;
2379+
}
2380+
}
2381+
}
2382+
return m_default_address_type;
23732383

23742384
if (has_bech32m_spkman) {
23752385
return OutputType::BECH32M;

test/functional/wallet_taproot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ def set_test_params(self):
194194
self.num_nodes = 2
195195
self.setup_clean_chain = True
196196
self.extra_args = [['-keypool=100'], ['-keypool=100']]
197+
for ea in self.extra_args:
198+
ea.append('-addresstype=bech32m')
197199
self.supports_cli = False
198200

199201
def skip_test_if_missing_module(self):

0 commit comments

Comments
 (0)