Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent Payments: receiving #28202

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class Chain
//! Return whether node has the block and optionally return block metadata
//! or contents.
virtual bool findBlock(const uint256& hash, const FoundBlock& block={}) = 0;
virtual bool getUndoBlock(const uint256& block_hash, CBlockUndo& blockUndo) = 0;

//! Find first block in the chain with timestamp >= the given time
//! and height >= than the given height, return false if there is no block
Expand Down
7 changes: 7 additions & 0 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,13 @@ class ChainImpl : public Chain
WAIT_LOCK(cs_main, lock);
return FillBlock(chainman().m_blockman.LookupBlockIndex(hash), block, lock, chainman().ActiveChain(), chainman().m_blockman);
}
bool getUndoBlock(const uint256& block_hash, CBlockUndo& undoBlock) override
{
WAIT_LOCK(cs_main, lock);
const CBlockIndex* pindex{chainman().m_blockman.LookupBlockIndex(block_hash)};
if (!chainman().m_blockman.UndoReadFromDisk(undoBlock, *pindex)) return false;
return true;
}
bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock& block) override
{
WAIT_LOCK(cs_main, lock);
Expand Down
13 changes: 13 additions & 0 deletions src/wallet/scriptpubkeyman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,4 +2821,17 @@ bool DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor(const WalletDescript

return true;
}

std::vector<CKey> DescriptorScriptPubKeyMan::VerifySilentPaymentAddress(
std::vector<XOnlyPubKey>& tx_output_pub_keys,
const CPubKey& sender_pub_key,
const std::vector<COutPoint>& tx_outpoints)
{
LOCK(cs_desc_man);
std::vector<CKey> raw_tr_keys;
LoadSilentRecipient();
assert(m_silent_recipient != nullptr);
m_silent_recipient->ComputeECDHSharedSecret(sender_pub_key, tx_outpoints);
return m_silent_recipient->ScanTxOutputs(tx_output_pub_keys);
}
} // namespace wallet
2 changes: 2 additions & 0 deletions src/wallet/scriptpubkeyman.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
bool GetDescriptorString(std::string& out, const bool priv) const;

void UpgradeDescriptorCache();

std::vector<CKey> VerifySilentPaymentAddress(std::vector<XOnlyPubKey>& txOutputPubKeys, const CPubKey& senderPubKey, const std::vector<COutPoint>& tx_outpoints);
};

/** struct containing information needed for migrating legacy wallets to descriptor wallets */
Expand Down
Loading