PIVX Core  5.6.99
P2P Digital Currency
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
SaplingScriptPubKeyMan Class Reference

#include <saplingscriptpubkeyman.h>

Collaboration diagram for SaplingScriptPubKeyMan:
[legend]

Public Member Functions

 SaplingScriptPubKeyMan (CWallet *parent)
 
 ~SaplingScriptPubKeyMan ()
 
void AddToSaplingSpends (const uint256 &nullifier, const uint256 &wtxid)
 Keep track of the used nullifier. More...
 
bool IsSaplingSpent (const SaplingOutPoint &op) const
 
bool IsSaplingSpent (const uint256 &nullifier) const
 
bool BuildWitnessChain (const CBlockIndex *pTargetBlock, const Consensus::Params &params, std::string &errorStr)
 Build the old witness chain. More...
 
void IncrementNoteWitnesses (const CBlockIndex *pindex, const CBlock *pblock, SaplingMerkleTree &saplingTree)
 pindex is the new tip being connected. More...
 
void DecrementNoteWitnesses (const CBlockIndex *pindex)
 pindex is the old tip being disconnected. More...
 
void UpdateNullifierNoteMapWithTx (const CWalletTx &wtx)
 Update mapSaplingNullifiersToNotes with the cached nullifiers in this tx. More...
 
void UpdateSaplingNullifierNoteMap (SaplingNoteData &nd, const SaplingOutPoint &op, const Optional< uint256 > &nullifier)
 Update mapSaplingNullifiersToNotes, and NoteData of a specific outpoint, directly with nullifier provided by the caller. More...
 
void UpdateSaplingNullifierNoteMapWithTx (CWalletTx &wtx)
 Update mapSaplingNullifiersToNotes, computing the nullifier from a cached witness if necessary. More...
 
void UpdateSaplingNullifierNoteMapForBlock (const CBlock *pblock)
 Iterate over transactions in a block and update the cached Sapling nullifiers for transactions which belong to the wallet. More...
 
bool SetupGeneration (const CKeyID &keyID, bool force=false, bool memonly=false)
 Set and initialize the Sapling HD chain. More...
 
bool IsEnabled () const
 
void SetHDSeed (const CPubKey &key, bool force=false, bool memonly=false)
 
void SetHDSeed (const CKeyID &keyID, bool force=false, bool memonly=false)
 
void SetHDChain (CHDChain &chain, bool memonly)
 
const CHDChainGetHDChain () const
 
uint256 getCommonOVK ()
 
void setCommonOVK (const uint256 &ovk)
 
bool EncryptSaplingKeys (CKeyingMaterial &vMasterKeyIn)
 
void GetConflicts (const CWalletTx &wtx, std::set< uint256 > &result) const
 
int64_t GetKeyCreationTime (const libzcash::SaplingIncomingViewingKey &ivk)
 
KeyAddResult AddViewingKeyToWallet (const libzcash::SaplingExtendedFullViewingKey &extfvk) const
 
KeyAddResult AddSpendingKeyToWallet (const Consensus::Params &params, const libzcash::SaplingExtendedSpendingKey &sk, int64_t nTime)
 
libzcash::SaplingPaymentAddress GenerateNewSaplingZKey ()
 Generates new Sapling key. More...
 
bool AddSaplingZKey (const libzcash::SaplingExtendedSpendingKey &key)
 Adds Sapling spending key to the store, and saves it to disk. More...
 
bool AddSaplingIncomingViewingKey (const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingPaymentAddress &addr)
 
bool AddCryptedSaplingSpendingKeyDB (const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector< unsigned char > &vchCryptedSecret)
 
bool HaveSpendingKeyForPaymentAddress (const libzcash::SaplingPaymentAddress &zaddr) const
 Returns true if the wallet contains the spending key. More...
 
bool PaymentAddressBelongsToWallet (const libzcash::SaplingPaymentAddress &zaddr) const
 Returns true if the wallet contains the spending and viewing key for the shielded address. More...
 
bool LoadSaplingZKey (const libzcash::SaplingExtendedSpendingKey &key)
 Adds spending key to the store, without saving it to disk (used by LoadWallet) More...
 
bool LoadSaplingZKeyMetadata (const libzcash::SaplingIncomingViewingKey &ivk, const CKeyMetadata &meta)
 Load spending key metadata (used by LoadWallet) More...
 
bool LoadCryptedSaplingZKey (const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector< unsigned char > &vchCryptedSecret)
 Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet) More...
 
bool LoadSaplingPaymentAddress (const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk)
 Adds a Sapling payment address -> incoming viewing key map entry, without saving it to disk (used by LoadWallet) More...
 
bool AddSaplingSpendingKey (const libzcash::SaplingExtendedSpendingKey &sk)
 
Optional< libzcash::SaplingExtendedFullViewingKeyGetViewingKeyForPaymentAddress (const libzcash::SaplingPaymentAddress &addr) const
 Return the full viewing key for the shielded address. More...
 
Optional< libzcash::SaplingExtendedSpendingKeyGetSpendingKeyForPaymentAddress (const libzcash::SaplingPaymentAddress &addr) const
 Return the spending key for the payment address (nullopt if the wallet has no spending key for such address) More...
 
std::pair< mapSaplingNoteData_t, SaplingIncomingViewingKeyMapFindMySaplingNotes (const CTransaction &tx) const
 Finds all output notes in the given tx that have been sent to a SaplingPaymentAddress in this wallet. More...
 
std::vector< libzcash::SaplingPaymentAddressFindMySaplingAddresses (const CTransaction &tx) const
 Find all of the addresses in the given tx that have been sent to a SaplingPaymentAddress in this wallet. More...
 
void GetNotes (const std::vector< SaplingOutPoint > &saplingOutpoints, std::vector< SaplingNoteEntry > &saplingEntriesRet) const
 Find notes for the outpoints. More...
 
void GetFilteredNotes (std::vector< SaplingNoteEntry > &saplingEntries, Optional< libzcash::SaplingPaymentAddress > &address, int minDepth=1, bool ignoreSpent=true, bool requireSpendingKey=true, bool ignoreLocked=true) const
 Find notes in the wallet filtered by payment address, min depth and ability to spend and if the notes are locked. More...
 
void GetFilteredNotes (std::vector< SaplingNoteEntry > &saplingEntries, std::set< libzcash::PaymentAddress > &filterAddresses, int minDepth=1, int maxDepth=INT_MAX, bool ignoreSpent=true, bool requireSpendingKey=true, bool ignoreLocked=true) const
 Find notes in the wallet filtered by payment addresses, min depth, max depth, if the note is spent, if a spending key is required, and if the notes are locked. More...
 
std::map< libzcash::SaplingPaymentAddress, std::vector< SaplingNoteEntry > > ListNotes () const
 
Optional< libzcash::SaplingPaymentAddressGetAddressFromInputIfPossible (const CWalletTx *wtx, int index) const
 Return the address from where the shielded spend is taking the funds from (if possible) More...
 
Optional< libzcash::SaplingPaymentAddressGetAddressFromInputIfPossible (const uint256 &txHash, int index) const
 
bool IsSaplingNullifierFromMe (const uint256 &nullifier) const
 Whether the nullifier is from this wallet. More...
 
void GetSaplingNoteWitnesses (const std::vector< SaplingOutPoint > &notes, std::vector< Optional< SaplingWitness >> &witnesses, uint256 &final_anchor) const
 Return all of the witnesses for the input notes. More...
 
std::set< std::pair< libzcash::PaymentAddress, uint256 > > GetNullifiersForAddresses (const std::set< libzcash::PaymentAddress > &addresses) const
 
bool IsNoteSaplingChange (const std::set< std::pair< libzcash::PaymentAddress, uint256 >> &nullifierSet, const libzcash::PaymentAddress &address, const SaplingOutPoint &entry) const
 
Optional< std::pair< libzcash::SaplingNotePlaintext, libzcash::SaplingPaymentAddress > > TryToRecoverNote (const CWalletTx &tx, const SaplingOutPoint &op)
 Try to recover the note using the wallet's ovks (mostly used when the outpoint is a debit) More...
 
isminetype IsMine (const CWalletTx &wtx, const SaplingOutPoint &op) const
 Return true if the wallet can decrypt & spend the shielded output. More...
 
Optional< libzcash::SaplingPaymentAddressGetOutPointAddress (const CWalletTx &tx, const SaplingOutPoint &op) const
 Return the shielded address of a specific outpoint of wallet transaction. More...
 
CAmount GetOutPointValue (const CWalletTx &tx, const SaplingOutPoint &op) const
 Return the shielded value of a specific outpoint of wallet transaction. More...
 
Optional< std::string > GetOutPointMemo (const CWalletTx &tx, const SaplingOutPoint &op) const
 Return the memo value of a specific outpoint of wallet transaction. More...
 
CAmount GetCredit (const CWalletTx &tx, const isminefilter &filter, const bool fUnspent=false) const
 Return the shielded credit of the tx. More...
 
CAmount GetDebit (const CTransaction &tx, const isminefilter &filter) const
 Return the shielded debit of the tx. More...
 
CAmount GetShieldedChange (const CWalletTx &wtx) const
 Return the shielded change of the tx. More...
 
bool IsNoteSaplingChange (const SaplingOutPoint &op, libzcash::SaplingPaymentAddress address) const
 Check whether an specific output is change or not. More...
 
bool UpdatedNoteData (const CWalletTx &wtxIn, CWalletTx &wtx)
 Update note data if is needed. More...
 
void ClearNoteWitnessCache ()
 Clear every notesData from every wallet tx and reset the witness cache size. More...
 

Public Attributes

std::map< libzcash::SaplingIncomingViewingKey, CKeyMetadatamapSaplingZKeyMetadata
 
int64_t nWitnessCacheSize {0}
 
bool nWitnessCacheNeedsUpdate {false}
 
std::map< uint256, SaplingOutPointmapSaplingNullifiersToNotes
 The reverse mapping of nullifiers to notes. More...
 

Private Types

typedef std::multimap< uint256, uint256TxNullifiers
 Used to keep track of spent Notes, and detect and report conflicts (double-spends). More...
 

Private Member Functions

uint256 getCommonOVKFromSeed () const
 

Private Attributes

std::map< uint256, std::list< SaplingWitness > > cachedWitnessMap
 
int rollbackTargetHeight = -1
 
CWalletwallet {nullptr}
 
CHDChain hdChain
 
Optional< uint256commonOVK
 
TxNullifiers mapTxSaplingNullifiers
 

Detailed Description

Definition at line 147 of file saplingscriptpubkeyman.h.

Member Typedef Documentation

◆ TxNullifiers

typedef std::multimap<uint256, uint256> SaplingScriptPubKeyMan::TxNullifiers
private

Used to keep track of spent Notes, and detect and report conflicts (double-spends).

Definition at line 435 of file saplingscriptpubkeyman.h.

Constructor & Destructor Documentation

◆ SaplingScriptPubKeyMan()

SaplingScriptPubKeyMan::SaplingScriptPubKeyMan ( CWallet parent)
inlineexplicit

Definition at line 150 of file saplingscriptpubkeyman.h.

◆ ~SaplingScriptPubKeyMan()

SaplingScriptPubKeyMan::~SaplingScriptPubKeyMan ( )
inline

Definition at line 152 of file saplingscriptpubkeyman.h.

Member Function Documentation

◆ AddCryptedSaplingSpendingKeyDB()

bool SaplingScriptPubKeyMan::AddCryptedSaplingSpendingKeyDB ( const libzcash::SaplingExtendedFullViewingKey extfvk,
const std::vector< unsigned char > &  vchCryptedSecret 
)

Definition at line 1292 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ AddSaplingIncomingViewingKey()

bool SaplingScriptPubKeyMan::AddSaplingIncomingViewingKey ( const libzcash::SaplingIncomingViewingKey ivk,
const libzcash::SaplingPaymentAddress addr 
)

Definition at line 1253 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ AddSaplingSpendingKey()

bool SaplingScriptPubKeyMan::AddSaplingSpendingKey ( const libzcash::SaplingExtendedSpendingKey sk)

Definition at line 1223 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddSaplingZKey()

bool SaplingScriptPubKeyMan::AddSaplingZKey ( const libzcash::SaplingExtendedSpendingKey key)

Adds Sapling spending key to the store, and saves it to disk.

Definition at line 1202 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddSpendingKeyToWallet()

KeyAddResult SaplingScriptPubKeyMan::AddSpendingKeyToWallet ( const Consensus::Params params,
const libzcash::SaplingExtendedSpendingKey sk,
int64_t  nTime 
)
Todo:
: Update epoch before release v5.

Definition at line 1168 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddToSaplingSpends()

void SaplingScriptPubKeyMan::AddToSaplingSpends ( const uint256 nullifier,
const uint256 wtxid 
)

Keep track of the used nullifier.

Definition at line 21 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddViewingKeyToWallet()

KeyAddResult SaplingScriptPubKeyMan::AddViewingKeyToWallet ( const libzcash::SaplingExtendedFullViewingKey extfvk) const

Definition at line 1156 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildWitnessChain()

bool SaplingScriptPubKeyMan::BuildWitnessChain ( const CBlockIndex pTargetBlock,
const Consensus::Params params,
std::string &  errorStr 
)

Build the old witness chain.

Definition at line 222 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ ClearNoteWitnessCache()

void SaplingScriptPubKeyMan::ClearNoteWitnessCache ( )

Clear every notesData from every wallet tx and reset the witness cache size.

Definition at line 1045 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ DecrementNoteWitnesses()

void SaplingScriptPubKeyMan::DecrementNoteWitnesses ( const CBlockIndex pindex)

pindex is the old tip being disconnected.

Todo:
: If nWitnessCache is zero, we need to regenerate the caches (#1302)

Definition at line 467 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ EncryptSaplingKeys()

bool SaplingScriptPubKeyMan::EncryptSaplingKeys ( CKeyingMaterial vMasterKeyIn)

Definition at line 1270 of file saplingscriptpubkeyman.cpp.

◆ FindMySaplingAddresses()

std::vector< libzcash::SaplingPaymentAddress > SaplingScriptPubKeyMan::FindMySaplingAddresses ( const CTransaction tx) const

Find all of the addresses in the given tx that have been sent to a SaplingPaymentAddress in this wallet.

Definition at line 562 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindMySaplingNotes()

std::pair< mapSaplingNoteData_t, SaplingIncomingViewingKeyMap > SaplingScriptPubKeyMan::FindMySaplingNotes ( const CTransaction tx) const

Finds all output notes in the given tx that have been sent to a SaplingPaymentAddress in this wallet.

Finds all output notes in the given transaction that have been sent to SaplingPaymentAddresses in this wallet.

It should never be necessary to call this method with a CWalletTx, because the result of FindMySaplingNotes (for the addresses available at the time) will already have been cached in CWalletTx.mapSaplingNoteData.

Definition at line 514 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GenerateNewSaplingZKey()

libzcash::SaplingPaymentAddress SaplingScriptPubKeyMan::GenerateNewSaplingZKey ( )

Generates new Sapling key.

Todo:
: Should be Sapling address format, SaplingPaymentAddress

Definition at line 1085 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetAddressFromInputIfPossible() [1/2]

Optional< libzcash::SaplingPaymentAddress > SaplingScriptPubKeyMan::GetAddressFromInputIfPossible ( const CWalletTx wtx,
int  index 
) const

Return the address from where the shielded spend is taking the funds from (if possible)

Definition at line 728 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ GetAddressFromInputIfPossible() [2/2]

Optional< libzcash::SaplingPaymentAddress > SaplingScriptPubKeyMan::GetAddressFromInputIfPossible ( const uint256 txHash,
int  index 
) const

Definition at line 720 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ getCommonOVK()

uint256 SaplingScriptPubKeyMan::getCommonOVK ( )

Definition at line 1412 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCommonOVKFromSeed()

uint256 SaplingScriptPubKeyMan::getCommonOVKFromSeed ( ) const
private

Definition at line 1434 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetConflicts()

void SaplingScriptPubKeyMan::GetConflicts ( const CWalletTx wtx,
std::set< uint256 > &  result 
) const

Definition at line 1137 of file saplingscriptpubkeyman.cpp.

◆ GetCredit()

CAmount SaplingScriptPubKeyMan::GetCredit ( const CWalletTx tx,
const isminefilter filter,
const bool  fUnspent = false 
) const

Return the shielded credit of the tx.

Definition at line 870 of file saplingscriptpubkeyman.cpp.

◆ GetDebit()

CAmount SaplingScriptPubKeyMan::GetDebit ( const CTransaction tx,
const isminefilter filter 
) const

Return the shielded debit of the tx.

Definition at line 905 of file saplingscriptpubkeyman.cpp.

◆ GetFilteredNotes() [1/2]

void SaplingScriptPubKeyMan::GetFilteredNotes ( std::vector< SaplingNoteEntry > &  saplingEntries,
Optional< libzcash::SaplingPaymentAddress > &  address,
int  minDepth = 1,
bool  ignoreSpent = true,
bool  requireSpendingKey = true,
bool  ignoreLocked = true 
) const

Find notes in the wallet filtered by payment address, min depth and ability to spend and if the notes are locked.

These notes are decrypted and added to the output parameter vector, saplingEntries.

Definition at line 618 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFilteredNotes() [2/2]

void SaplingScriptPubKeyMan::GetFilteredNotes ( std::vector< SaplingNoteEntry > &  saplingEntries,
std::set< libzcash::PaymentAddress > &  filterAddresses,
int  minDepth = 1,
int  maxDepth = INT_MAX,
bool  ignoreSpent = true,
bool  requireSpendingKey = true,
bool  ignoreLocked = true 
) const

Find notes in the wallet filtered by payment addresses, min depth, max depth, if the note is spent, if a spending key is required, and if the notes are locked.

These notes are decrypted and added to the output parameter vector, saplingEntries.

Definition at line 640 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetHDChain()

const CHDChain& SaplingScriptPubKeyMan::GetHDChain ( ) const
inline

Definition at line 216 of file saplingscriptpubkeyman.h.

Here is the caller graph for this function:

◆ GetKeyCreationTime()

int64_t SaplingScriptPubKeyMan::GetKeyCreationTime ( const libzcash::SaplingIncomingViewingKey ivk)

Definition at line 1131 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ GetNotes()

void SaplingScriptPubKeyMan::GetNotes ( const std::vector< SaplingOutPoint > &  saplingOutpoints,
std::vector< SaplingNoteEntry > &  saplingEntriesRet 
) const

Find notes for the outpoints.

Definition at line 585 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ GetNullifiersForAddresses()

std::set< std::pair< libzcash::PaymentAddress, uint256 > > SaplingScriptPubKeyMan::GetNullifiersForAddresses ( const std::set< libzcash::PaymentAddress > &  addresses) const

Definition at line 748 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOutPointAddress()

Optional< libzcash::SaplingPaymentAddress > SaplingScriptPubKeyMan::GetOutPointAddress ( const CWalletTx tx,
const SaplingOutPoint op 
) const

Return the shielded address of a specific outpoint of wallet transaction.

Definition at line 783 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ GetOutPointMemo()

Optional< std::string > SaplingScriptPubKeyMan::GetOutPointMemo ( const CWalletTx tx,
const SaplingOutPoint op 
) const

Return the memo value of a specific outpoint of wallet transaction.

Definition at line 801 of file saplingscriptpubkeyman.cpp.

◆ GetOutPointValue()

CAmount SaplingScriptPubKeyMan::GetOutPointValue ( const CWalletTx tx,
const SaplingOutPoint op 
) const

Return the shielded value of a specific outpoint of wallet transaction.

Definition at line 792 of file saplingscriptpubkeyman.cpp.

◆ GetSaplingNoteWitnesses()

void SaplingScriptPubKeyMan::GetSaplingNoteWitnesses ( const std::vector< SaplingOutPoint > &  notes,
std::vector< Optional< SaplingWitness >> &  witnesses,
uint256 final_anchor 
) const

Return all of the witnesses for the input notes.

Definition at line 993 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ GetShieldedChange()

CAmount SaplingScriptPubKeyMan::GetShieldedChange ( const CWalletTx wtx) const

Return the shielded change of the tx.

Definition at line 941 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSpendingKeyForPaymentAddress()

Optional< libzcash::SaplingExtendedSpendingKey > SaplingScriptPubKeyMan::GetSpendingKeyForPaymentAddress ( const libzcash::SaplingPaymentAddress addr) const

Return the spending key for the payment address (nullopt if the wallet has no spending key for such address)

Definition at line 1058 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetViewingKeyForPaymentAddress()

Optional< libzcash::SaplingExtendedFullViewingKey > SaplingScriptPubKeyMan::GetViewingKeyForPaymentAddress ( const libzcash::SaplingPaymentAddress addr) const

Return the full viewing key for the shielded address.

Definition at line 1068 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HaveSpendingKeyForPaymentAddress()

bool SaplingScriptPubKeyMan::HaveSpendingKeyForPaymentAddress ( const libzcash::SaplingPaymentAddress zaddr) const

Returns true if the wallet contains the spending key.

Definition at line 1312 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IncrementNoteWitnesses()

void SaplingScriptPubKeyMan::IncrementNoteWitnesses ( const CBlockIndex pindex,
const CBlock pblock,
SaplingMerkleTree saplingTree 
)

pindex is the new tip being connected.

Definition at line 313 of file saplingscriptpubkeyman.cpp.

◆ IsEnabled()

bool SaplingScriptPubKeyMan::IsEnabled ( ) const
inline

Definition at line 205 of file saplingscriptpubkeyman.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsMine()

isminetype SaplingScriptPubKeyMan::IsMine ( const CWalletTx wtx,
const SaplingOutPoint op 
) const

Return true if the wallet can decrypt & spend the shielded output.

Definition at line 859 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsNoteSaplingChange() [1/2]

bool SaplingScriptPubKeyMan::IsNoteSaplingChange ( const SaplingOutPoint op,
libzcash::SaplingPaymentAddress  address 
) const

Check whether an specific output is change or not.

Definition at line 964 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ IsNoteSaplingChange() [2/2]

bool SaplingScriptPubKeyMan::IsNoteSaplingChange ( const std::set< std::pair< libzcash::PaymentAddress, uint256 >> &  nullifierSet,
const libzcash::PaymentAddress address,
const SaplingOutPoint entry 
) const

Definition at line 972 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ IsSaplingNullifierFromMe()

bool SaplingScriptPubKeyMan::IsSaplingNullifierFromMe ( const uint256 nullifier) const

Whether the nullifier is from this wallet.

Definition at line 741 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ IsSaplingSpent() [1/2]

bool SaplingScriptPubKeyMan::IsSaplingSpent ( const SaplingOutPoint op) const

Definition at line 31 of file saplingscriptpubkeyman.cpp.

Here is the caller graph for this function:

◆ IsSaplingSpent() [2/2]

bool SaplingScriptPubKeyMan::IsSaplingSpent ( const uint256 nullifier) const

Definition at line 42 of file saplingscriptpubkeyman.cpp.

◆ ListNotes()

std::map< libzcash::SaplingPaymentAddress, std::vector< SaplingNoteEntry > > SaplingScriptPubKeyMan::ListNotes ( ) const

Definition at line 706 of file saplingscriptpubkeyman.cpp.

◆ LoadCryptedSaplingZKey()

bool SaplingScriptPubKeyMan::LoadCryptedSaplingZKey ( const libzcash::SaplingExtendedFullViewingKey extfvk,
const std::vector< unsigned char > &  vchCryptedSecret 
)

Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet)

Definition at line 1334 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ LoadSaplingPaymentAddress()

bool SaplingScriptPubKeyMan::LoadSaplingPaymentAddress ( const libzcash::SaplingPaymentAddress addr,
const libzcash::SaplingIncomingViewingKey ivk 
)

Adds a Sapling payment address -> incoming viewing key map entry, without saving it to disk (used by LoadWallet)

Definition at line 1353 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ LoadSaplingZKey()

bool SaplingScriptPubKeyMan::LoadSaplingZKey ( const libzcash::SaplingExtendedSpendingKey key)

Adds spending key to the store, without saving it to disk (used by LoadWallet)

Definition at line 1348 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ LoadSaplingZKeyMetadata()

bool SaplingScriptPubKeyMan::LoadSaplingZKeyMetadata ( const libzcash::SaplingIncomingViewingKey ivk,
const CKeyMetadata meta 
)

Load spending key metadata (used by LoadWallet)

Definition at line 1341 of file saplingscriptpubkeyman.cpp.

◆ PaymentAddressBelongsToWallet()

bool SaplingScriptPubKeyMan::PaymentAddressBelongsToWallet ( const libzcash::SaplingPaymentAddress zaddr) const

Returns true if the wallet contains the spending and viewing key for the shielded address.

Definition at line 1322 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ setCommonOVK()

void SaplingScriptPubKeyMan::setCommonOVK ( const uint256 ovk)
inline

Definition at line 224 of file saplingscriptpubkeyman.h.

◆ SetHDChain()

void SaplingScriptPubKeyMan::SetHDChain ( CHDChain chain,
bool  memonly 
)

Definition at line 1396 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetHDSeed() [1/2]

void SaplingScriptPubKeyMan::SetHDSeed ( const CKeyID keyID,
bool  force = false,
bool  memonly = false 
)

Definition at line 1373 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ SetHDSeed() [2/2]

void SaplingScriptPubKeyMan::SetHDSeed ( const CPubKey key,
bool  force = false,
bool  memonly = false 
)

Definition at line 1368 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetupGeneration()

bool SaplingScriptPubKeyMan::SetupGeneration ( const CKeyID keyID,
bool  force = false,
bool  memonly = false 
)

Set and initialize the Sapling HD chain.

Definition at line 1362 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ TryToRecoverNote()

Optional< std::pair< libzcash::SaplingNotePlaintext, libzcash::SaplingPaymentAddress > > SaplingScriptPubKeyMan::TryToRecoverNote ( const CWalletTx tx,
const SaplingOutPoint op 
)

Try to recover the note using the wallet's ovks (mostly used when the outpoint is a debit)

Definition at line 819 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatedNoteData()

bool SaplingScriptPubKeyMan::UpdatedNoteData ( const CWalletTx wtxIn,
CWalletTx wtx 
)

Update note data if is needed.

Definition at line 1023 of file saplingscriptpubkeyman.cpp.

◆ UpdateNullifierNoteMapWithTx()

void SaplingScriptPubKeyMan::UpdateNullifierNoteMapWithTx ( const CWalletTx wtx)

Update mapSaplingNullifiersToNotes with the cached nullifiers in this tx.

Definition at line 120 of file saplingscriptpubkeyman.cpp.

◆ UpdateSaplingNullifierNoteMap()

void SaplingScriptPubKeyMan::UpdateSaplingNullifierNoteMap ( SaplingNoteData nd,
const SaplingOutPoint op,
const Optional< uint256 > &  nullifier 
)

Update mapSaplingNullifiersToNotes, and NoteData of a specific outpoint, directly with nullifier provided by the caller.

Definition at line 69 of file saplingscriptpubkeyman.cpp.

◆ UpdateSaplingNullifierNoteMapForBlock()

void SaplingScriptPubKeyMan::UpdateSaplingNullifierNoteMapForBlock ( const CBlock pblock)

Iterate over transactions in a block and update the cached Sapling nullifiers for transactions which belong to the wallet.

Definition at line 57 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:

◆ UpdateSaplingNullifierNoteMapWithTx()

void SaplingScriptPubKeyMan::UpdateSaplingNullifierNoteMapWithTx ( CWalletTx wtx)

Update mapSaplingNullifiersToNotes, computing the nullifier from a cached witness if necessary.

Definition at line 79 of file saplingscriptpubkeyman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cachedWitnessMap

std::map<uint256, std::list<SaplingWitness> > SaplingScriptPubKeyMan::cachedWitnessMap
private

Definition at line 420 of file saplingscriptpubkeyman.h.

◆ commonOVK

Optional<uint256> SaplingScriptPubKeyMan::commonOVK
private

Definition at line 427 of file saplingscriptpubkeyman.h.

◆ hdChain

CHDChain SaplingScriptPubKeyMan::hdChain
private

Definition at line 425 of file saplingscriptpubkeyman.h.

◆ mapSaplingNullifiersToNotes

std::map<uint256, SaplingOutPoint> SaplingScriptPubKeyMan::mapSaplingNullifiersToNotes

The reverse mapping of nullifiers to notes.

The mapping cannot be updated while an encrypted wallet is locked, because we need the SpendingKey to create the nullifier (zcash#1502). This has several implications for transactions added to the wallet while locked:

  • Parent transactions can't be marked dirty when a child transaction that spends their output notes is updated.
    • We currently don't cache any note values, so this is not a problem, yet.
  • GetFilteredNotes can't filter out spent notes.
    • Per the comment in SaplingNoteData, we assume that if we don't have a cached nullifier, the note is not spent.

Another more problematic implication is that the wallet can fail to detect transactions on the blockchain that spend our notes. There are two possible cases in which this could happen:

  • We receive a note when the wallet is locked, and then spend it using a different wallet client.
  • We spend from a PaymentAddress we control, then we export the SpendingKey and import it into a new wallet, and reindex/rescan to find the old transactions.

The wallet will only miss "pure" spends - transactions that are only linked to us by the fact that they contain notes we spent. If it also sends notes to us, or interacts with our transparent addresses, we will detect the transaction and add it to the wallet (again without caching nullifiers for new notes). As by default JoinSplits send change back to the origin PaymentAddress, the wallet should rarely miss transactions.

To work around these issues, whenever the wallet is unlocked, we scan all cached notes, and cache any missing nullifiers. Since the wallet must be unlocked in order to spend notes, this means that GetFilteredNotes will always behave correctly within that context (and any other uses will give correct responses afterwards), for the transactions that the wallet was able to detect. Any missing transactions can be rediscovered by:

  • Unlocking the wallet (to fill all nullifier caches).
  • Restarting the node with -reindex (which operates on a locked wallet but with the now-cached nullifiers).

Definition at line 416 of file saplingscriptpubkeyman.h.

◆ mapSaplingZKeyMetadata

std::map<libzcash::SaplingIncomingViewingKey, CKeyMetadata> SaplingScriptPubKeyMan::mapSaplingZKeyMetadata

Definition at line 357 of file saplingscriptpubkeyman.h.

◆ mapTxSaplingNullifiers

TxNullifiers SaplingScriptPubKeyMan::mapTxSaplingNullifiers
private

Definition at line 436 of file saplingscriptpubkeyman.h.

◆ nWitnessCacheNeedsUpdate

bool SaplingScriptPubKeyMan::nWitnessCacheNeedsUpdate {false}

Definition at line 365 of file saplingscriptpubkeyman.h.

◆ nWitnessCacheSize

int64_t SaplingScriptPubKeyMan::nWitnessCacheSize {0}

Definition at line 364 of file saplingscriptpubkeyman.h.

◆ rollbackTargetHeight

int SaplingScriptPubKeyMan::rollbackTargetHeight = -1
private

Definition at line 421 of file saplingscriptpubkeyman.h.

◆ wallet

CWallet* SaplingScriptPubKeyMan::wallet {nullptr}
private

Definition at line 423 of file saplingscriptpubkeyman.h.


The documentation for this class was generated from the following files: