5 #ifndef PIVX_SAPLING_SAPLINGSCRIPTPUBKEYMAN_H
6 #define PIVX_SAPLING_SAPLINGSCRIPTPUBKEYMAN_H
21 static const unsigned int WITNESS_CACHE_SIZE = DEFAULT_MAX_REORG_DEPTH + 1;
32 const std::array<unsigned char, ZC_MEMO_SIZE>& _memo,
39 std::array<unsigned char, ZC_MEMO_SIZE>
memo;
102 int nVersion = s.GetVersion();
211 void SetHDSeed(
const CPubKey& key,
bool force =
false,
bool memonly =
false);
212 void SetHDSeed(
const CKeyID& keyID,
bool force =
false,
bool memonly =
false);
252 const std::vector<unsigned char> &vchCryptedSecret);
264 const std::vector<unsigned char> &vchCryptedSecret);
287 void GetNotes(
const std::vector<SaplingOutPoint>& saplingOutpoints,
288 std::vector<SaplingNoteEntry>& saplingEntriesRet)
const;
294 bool ignoreSpent =
true,
295 bool requireSpendingKey =
true,
296 bool ignoreLocked =
true)
const;
301 std::set<libzcash::PaymentAddress>& filterAddresses,
303 int maxDepth=INT_MAX,
304 bool ignoreSpent=
true,
305 bool requireSpendingKey=
true,
306 bool ignoreLocked=
true)
const;
309 std::map<libzcash::SaplingPaymentAddress, std::vector<SaplingNoteEntry>>
ListNotes()
const;
320 const std::vector<SaplingOutPoint>& notes,
324 std::set<std::pair<libzcash::PaymentAddress, uint256>>
GetNullifiersForAddresses(
const std::set<libzcash::PaymentAddress> & addresses)
const;
int64_t CAmount
Amount in PIV (Can be negative)
The block chain is a tree shaped structure starting with the genesis block at the root,...
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
The basic transaction that is broadcasted on the network and contained in blocks.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
A transaction with a bunch of additional info that only the owner cares about.
SaplingNoteData(const libzcash::SaplingIncomingViewingKey &_ivk)
Optional< CAmount > amount
Cached note amount.
SERIALIZE_METHODS(SaplingNoteData, obj)
Optional< uint256 > nullifier
Cached note nullifier.
friend bool operator==(const SaplingNoteData &a, const SaplingNoteData &b)
std::list< SaplingWitness > witnesses
Optional< std::array< unsigned char, ZC_MEMO_SIZE > > memo
Cached note memo (only for non-empty memo) It will be loaded the first time that the note is decrypte...
Optional< libzcash::SaplingIncomingViewingKey > ivk
friend bool operator!=(const SaplingNoteData &a, const SaplingNoteData &b)
int witnessHeight
Block height corresponding to the most current witness.
SaplingNoteData(const libzcash::SaplingIncomingViewingKey &_ivk, const uint256 &n)
Optional< libzcash::SaplingPaymentAddress > address
Cached shielded address It will be loaded the first time that the note is decrypted (when the tx is a...
An outpoint - a combination of a transaction hash and an index n into its sapling output description ...
std::map< libzcash::SaplingIncomingViewingKey, CKeyMetadata > mapSaplingZKeyMetadata
bool BuildWitnessChain(const CBlockIndex *pTargetBlock, const Consensus::Params ¶ms, std::string &errorStr)
Build the old witness chain.
bool LoadSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key)
Adds spending key to the store, without saving it to disk (used by LoadWallet)
SaplingScriptPubKeyMan(CWallet *parent)
bool UpdatedNoteData(const CWalletTx &wtxIn, CWalletTx &wtx)
Update note data if is needed.
bool IsNoteSaplingChange(const std::set< std::pair< libzcash::PaymentAddress, uint256 >> &nullifierSet, const libzcash::PaymentAddress &address, const SaplingOutPoint &entry) const
Optional< std::string > GetOutPointMemo(const CWalletTx &tx, const SaplingOutPoint &op) const
Return the memo value of a specific outpoint of wallet transaction.
int64_t GetKeyCreationTime(const libzcash::SaplingIncomingViewingKey &ivk)
std::multimap< uint256, uint256 > TxNullifiers
Used to keep track of spent Notes, and detect and report conflicts (double-spends).
bool IsSaplingSpent(const SaplingOutPoint &op) const
bool IsSaplingNullifierFromMe(const uint256 &nullifier) const
Whether the nullifier is from this wallet.
Optional< libzcash::SaplingExtendedFullViewingKey > GetViewingKeyForPaymentAddress(const libzcash::SaplingPaymentAddress &addr) const
Return the full viewing key for the shielded address.
bool HaveSpendingKeyForPaymentAddress(const libzcash::SaplingPaymentAddress &zaddr) const
Returns true if the wallet contains the spending key.
std::vector< libzcash::SaplingPaymentAddress > FindMySaplingAddresses(const CTransaction &tx) const
Find all of the addresses in the given tx that have been sent to a SaplingPaymentAddress in this wall...
bool AddCryptedSaplingSpendingKeyDB(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector< unsigned char > &vchCryptedSecret)
void AddToSaplingSpends(const uint256 &nullifier, const uint256 &wtxid)
Keep track of the used nullifier.
std::map< libzcash::SaplingPaymentAddress, std::vector< SaplingNoteEntry > > ListNotes() const
Optional< libzcash::SaplingExtendedSpendingKey > GetSpendingKeyForPaymentAddress(const libzcash::SaplingPaymentAddress &addr) const
Return the spending key for the payment address (nullopt if the wallet has no spending key for such a...
bool AddSaplingSpendingKey(const libzcash::SaplingExtendedSpendingKey &sk)
int64_t nWitnessCacheSize
void IncrementNoteWitnesses(const CBlockIndex *pindex, const CBlock *pblock, SaplingMerkleTree &saplingTree)
pindex is the new tip being connected.
bool nWitnessCacheNeedsUpdate
void UpdateSaplingNullifierNoteMap(SaplingNoteData &nd, const SaplingOutPoint &op, const Optional< uint256 > &nullifier)
Update mapSaplingNullifiersToNotes, and NoteData of a specific outpoint, directly with nullifier prov...
uint256 getCommonOVKFromSeed() const
CAmount GetCredit(const CWalletTx &tx, const isminefilter &filter, const bool fUnspent=false) const
Return the shielded credit of the tx.
bool SetupGeneration(const CKeyID &keyID, bool force=false, bool memonly=false)
Set and initialize the Sapling HD chain.
const CHDChain & GetHDChain() const
void UpdateNullifierNoteMapWithTx(const CWalletTx &wtx)
Update mapSaplingNullifiersToNotes with the cached nullifiers in this tx.
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)
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)
TxNullifiers mapTxSaplingNullifiers
isminetype IsMine(const CWalletTx &wtx, const SaplingOutPoint &op) const
Return true if the wallet can decrypt & spend the shielded output.
bool LoadSaplingZKeyMetadata(const libzcash::SaplingIncomingViewingKey &ivk, const CKeyMetadata &meta)
Load spending key metadata (used by LoadWallet)
Optional< libzcash::SaplingPaymentAddress > GetOutPointAddress(const CWalletTx &tx, const SaplingOutPoint &op) const
Return the shielded address of a specific outpoint of wallet transaction.
std::map< uint256, SaplingOutPoint > mapSaplingNullifiersToNotes
The reverse mapping of nullifiers to notes.
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 ...
KeyAddResult AddViewingKeyToWallet(const libzcash::SaplingExtendedFullViewingKey &extfvk) const
bool AddSaplingIncomingViewingKey(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingPaymentAddress &addr)
bool PaymentAddressBelongsToWallet(const libzcash::SaplingPaymentAddress &zaddr) const
Returns true if the wallet contains the spending and viewing key for the shielded address.
CAmount GetOutPointValue(const CWalletTx &tx, const SaplingOutPoint &op) const
Return the shielded value of a specific outpoint of wallet transaction.
std::map< uint256, std::list< SaplingWitness > > cachedWitnessMap
void GetNotes(const std::vector< SaplingOutPoint > &saplingOutpoints, std::vector< SaplingNoteEntry > &saplingEntriesRet) const
Find notes for the outpoints.
Optional< libzcash::SaplingPaymentAddress > GetAddressFromInputIfPossible(const CWalletTx *wtx, int index) const
Return the address from where the shielded spend is taking the funds from (if possible)
bool AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key)
Adds Sapling spending key to the store, and saves it to disk.
std::pair< mapSaplingNoteData_t, SaplingIncomingViewingKeyMap > FindMySaplingNotes(const CTransaction &tx) const
Finds all output notes in the given tx that have been sent to a SaplingPaymentAddress in this wallet.
void GetSaplingNoteWitnesses(const std::vector< SaplingOutPoint > ¬es, std::vector< Optional< SaplingWitness >> &witnesses, uint256 &final_anchor) const
Return all of the witnesses for the input notes.
void DecrementNoteWitnesses(const CBlockIndex *pindex)
pindex is the old tip being disconnected.
libzcash::SaplingPaymentAddress GenerateNewSaplingZKey()
Generates new Sapling key.
void setCommonOVK(const uint256 &ovk)
std::set< std::pair< libzcash::PaymentAddress, uint256 > > GetNullifiersForAddresses(const std::set< libzcash::PaymentAddress > &addresses) const
void SetHDSeed(const CPubKey &key, bool force=false, bool memonly=false)
Optional< uint256 > commonOVK
void UpdateSaplingNullifierNoteMapWithTx(CWalletTx &wtx)
Update mapSaplingNullifiersToNotes, computing the nullifier from a cached witness if necessary.
bool EncryptSaplingKeys(CKeyingMaterial &vMasterKeyIn)
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...
void SetHDChain(CHDChain &chain, bool memonly)
CAmount GetDebit(const CTransaction &tx, const isminefilter &filter) const
Return the shielded debit of the tx.
void UpdateSaplingNullifierNoteMapForBlock(const CBlock *pblock)
Iterate over transactions in a block and update the cached Sapling nullifiers for transactions which ...
void ClearNoteWitnessCache()
Clear every notesData from every wallet tx and reset the witness cache size.
void GetConflicts(const CWalletTx &wtx, std::set< uint256 > &result) const
CAmount GetShieldedChange(const CWalletTx &wtx) const
Return the shielded change of the tx.
~SaplingScriptPubKeyMan()
KeyAddResult AddSpendingKeyToWallet(const Consensus::Params ¶ms, const libzcash::SaplingExtendedSpendingKey &sk, int64_t nTime)
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
isminetype
IsMine() return codes.
uint8_t isminefilter
used for bitflags of isminetype
boost::variant< InvalidEncoding, SaplingPaymentAddress > PaymentAddress
boost::optional< T > Optional
Substitute for C++17 std::optional.
std::map< SaplingOutPoint, SaplingNoteData > mapSaplingNoteData_t
Parameters that influence chain consensus.
Sapling note, its location in a transaction, and number of confirmations.
SaplingNoteEntry(const SaplingOutPoint &_op, const libzcash::SaplingPaymentAddress &_addr, const libzcash::SaplingNote &_note, const std::array< unsigned char, ZC_MEMO_SIZE > &_memo, const int _conf)
libzcash::SaplingPaymentAddress address
std::array< unsigned char, ZC_MEMO_SIZE > memo
libzcash::SaplingNote note