mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Merge wallet_avoid_newerchange
This commit is contained in:
commit
13f9c5d677
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user