mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 16:24:48 +02:00
Add PubKeyDestination for P2PK scripts
P2PK scripts are not PKHash destinations, they should have their own type. This also results in no longer showing a p2pkh address for p2pk outputs. However for backwards compatibility, ListCoinst will still do this conversion.
This commit is contained in:
@@ -490,8 +490,15 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet)
|
||||
coins_params.skip_locked = false;
|
||||
for (const COutput& coin : AvailableCoins(wallet, &coin_control, /*feerate=*/std::nullopt, coins_params).All()) {
|
||||
CTxDestination address;
|
||||
if ((coin.spendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.solvable)) &&
|
||||
ExtractDestination(FindNonChangeParentOutput(wallet, coin.outpoint).scriptPubKey, address)) {
|
||||
if ((coin.spendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.solvable))) {
|
||||
if (!ExtractDestination(FindNonChangeParentOutput(wallet, coin.outpoint).scriptPubKey, address)) {
|
||||
// For backwards compatibility, we convert P2PK output scripts into PKHash destinations
|
||||
if (auto pk_dest = std::get_if<PubKeyDestination>(&address)) {
|
||||
address = PKHash(pk_dest->GetPubKey());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result[address].emplace_back(coin);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user