mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
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:
commit
381cd9cd01
7 changed files with 55 additions and 68 deletions
|
|
@ -3802,7 +3802,7 @@ bool CWallet::GetOnlinePakKey(CPubKey& online_pubkey, std::string& error)
|
|||
error.clear();
|
||||
auto spk_man = m_spk_man.get();
|
||||
if (spk_man) {
|
||||
if (!spk_man->GetKeyFromPool(online_pubkey)) {
|
||||
if (!spk_man->GetKeyFromPool(online_pubkey, OutputType::BECH32)) {
|
||||
error = "Error: Keypool ran out, please call keypoolrefill first";
|
||||
return false;
|
||||
}
|
||||
|
|
@ -4016,49 +4016,40 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!pwallet->CanGetAddresses(internal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nIndex == -1)
|
||||
{
|
||||
CKeyPool keypool;
|
||||
if (!m_spk_man->GetReservedDestination(type, internal, nIndex, keypool)) {
|
||||
if (!m_spk_man->GetReservedDestination(type, internal, address, nIndex, keypool)) {
|
||||
return false;
|
||||
}
|
||||
vchPubKey = keypool.vchPubKey;
|
||||
fInternal = keypool.fInternal;
|
||||
}
|
||||
assert(vchPubKey.IsValid());
|
||||
address = GetDestinationForKey(vchPubKey, type);
|
||||
dest = address;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReserveDestination::SetBlindingPubKey(const CPubKey& blinding_pubkey, CTxDestination& dest)
|
||||
{
|
||||
address = GetDestinationForKey(vchPubKey, type, blinding_pubkey);
|
||||
boost::apply_visitor(SetBlindingPubKeyVisitor(blinding_pubkey), address);
|
||||
dest = address;
|
||||
}
|
||||
|
||||
void ReserveDestination::KeepDestination()
|
||||
{
|
||||
if (nIndex != -1) {
|
||||
m_spk_man->KeepDestination(nIndex);
|
||||
m_spk_man->LearnRelatedScripts(vchPubKey, type);
|
||||
m_spk_man->KeepDestination(nIndex, type);
|
||||
}
|
||||
nIndex = -1;
|
||||
vchPubKey = CPubKey();
|
||||
address = CNoDestination();
|
||||
}
|
||||
|
||||
void ReserveDestination::ReturnDestination()
|
||||
{
|
||||
if (nIndex != -1) {
|
||||
m_spk_man->ReturnDestination(nIndex, fInternal, vchPubKey);
|
||||
m_spk_man->ReturnDestination(nIndex, fInternal, address);
|
||||
}
|
||||
nIndex = -1;
|
||||
vchPubKey = CPubKey();
|
||||
address = CNoDestination();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue