mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Opportunistically use bech32m change addresses if available
If a transaction as a segwit output, use a bech32m change address if they are available. If not, fallback to bech32. If bech32 change addresses are unavailable, fallback to the default address type.
This commit is contained in:
parent
0262536c34
commit
699dfcd8ad
1 changed files with 7 additions and 1 deletions
|
@ -1909,7 +1909,13 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
|
||||||
int witnessversion = 0;
|
int witnessversion = 0;
|
||||||
std::vector<unsigned char> witnessprogram;
|
std::vector<unsigned char> witnessprogram;
|
||||||
if (recipient.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
if (recipient.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
||||||
return OutputType::BECH32;
|
if (GetScriptPubKeyMan(OutputType::BECH32M, true)) {
|
||||||
|
return OutputType::BECH32M;
|
||||||
|
} else if (GetScriptPubKeyMan(OutputType::BECH32, true)) {
|
||||||
|
return OutputType::BECH32;
|
||||||
|
} else {
|
||||||
|
return m_default_address_type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue