Add getter and setter for sapling note data and update tests
This commit is contained in:
committed by
Simon
parent
29523dc778
commit
e6b0a8b9ee
@@ -1496,6 +1496,33 @@ void CWallet::GetSproutNoteWitnesses(std::vector<JSOutPoint> notes,
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::GetSaplingNoteWitnesses(std::vector<SaplingOutPoint> notes,
|
||||
std::vector<boost::optional<ZCSaplingIncrementalWitness>>& witnesses,
|
||||
uint256 &final_anchor)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
witnesses.resize(notes.size());
|
||||
boost::optional<uint256> rt;
|
||||
int i = 0;
|
||||
for (SaplingOutPoint note : notes) {
|
||||
if (mapWallet.count(note.hash) &&
|
||||
mapWallet[note.hash].mapSaplingNoteData.count(note) &&
|
||||
mapWallet[note.hash].mapSaplingNoteData[note].witnesses.size() > 0) {
|
||||
witnesses[i] = mapWallet[note.hash].mapSaplingNoteData[note].witnesses.front();
|
||||
if (!rt) {
|
||||
rt = witnesses[i]->root();
|
||||
} else {
|
||||
assert(*rt == witnesses[i]->root());
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
// All returned witnesses have the same anchor
|
||||
if (rt) {
|
||||
final_anchor = *rt;
|
||||
}
|
||||
}
|
||||
|
||||
isminetype CWallet::IsMine(const CTxIn &txin) const
|
||||
{
|
||||
{
|
||||
@@ -1643,6 +1670,18 @@ void CWalletTx::SetSproutNoteData(mapSproutNoteData_t ¬eData)
|
||||
}
|
||||
}
|
||||
|
||||
void CWalletTx::SetSaplingNoteData(mapSaplingNoteData_t ¬eData)
|
||||
{
|
||||
mapSaplingNoteData.clear();
|
||||
for (const std::pair<SaplingOutPoint, SaplingNoteData> nd : noteData) {
|
||||
if (nd.first.n < vShieldedOutput.size()) {
|
||||
mapSaplingNoteData[nd.first] = nd.second;
|
||||
} else {
|
||||
throw std::logic_error("CWalletTx::SetSaplingNoteData(): Invalid note");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t CWalletTx::GetTxTime() const
|
||||
{
|
||||
int64_t n = nTimeSmart;
|
||||
|
||||
Reference in New Issue
Block a user