Merge 4ee8a58ce7 into merged_master (Bitcoin PR #17373)

This PR associates OutputType::BECH32 to PAK online keys, where before we
were able to directly access keys from the keypool. In a future refactoring
we should give PAK keys their own output type (and own scriptpubkey manager)
so that the wallet won't accept payments "to the PAK key".

Also changes `ReserveDestination::SetBlindingPubKey` to use a visitor pattern
to apply a blinding pubkey to a destination directly, rather than using the
old hacky method of regenerating the destination by pulling its key (which
is no longer contained in the class) out and giving it to a new constructor.
This was a long-overdue refactoring and the minimal-diff way to get the code
compiling (and it's not bad, maybe 10LOC to add a new visitor class) but
nonetheless I apologize for sticking this into a merge commit.
This commit is contained in:
Andrew Poelstra 2020-11-14 16:51:54 +00:00
commit 381cd9cd01
7 changed files with 55 additions and 68 deletions

View file

@ -156,6 +156,22 @@ public:
}
};
// ELEMENTS
class SetBlindingPubKeyVisitor : public boost::static_visitor<>
{
public:
const CPubKey& blinding_pubkey;
explicit SetBlindingPubKeyVisitor(const CPubKey& blinding_pubkey_) : blinding_pubkey(blinding_pubkey_) {}
void operator()(CNoDestination &dest) const { }
void operator()(PKHash &dest) const { dest.blinding_pubkey = blinding_pubkey; }
void operator()(ScriptHash &dest) const { dest.blinding_pubkey = blinding_pubkey; }
void operator()(WitnessV0KeyHash &dest) const { dest.blinding_pubkey = blinding_pubkey; }
void operator()(WitnessV0ScriptHash &dest) const { dest.blinding_pubkey = blinding_pubkey; }
void operator()(WitnessUnknown &dest) const { dest.blinding_pubkey = blinding_pubkey; }
void operator()(NullData &dest) const { }
};
/**
* A txout script template with a specific destination. It is either:
* * CNoDestination: no destination set