Return std::optional for GetAnchor
This commit is contained in:
parent
437b8c488a
commit
fd34ecc64d
|
@ -1062,14 +1062,17 @@ std::optional<UnsatisfiedShieldedReq> CCoinsViewCache::HaveShieldedRequirements(
|
|||
}
|
||||
}
|
||||
|
||||
OrchardMerkleTree tree;
|
||||
if (!GetOrchardAnchorAt(tx.GetOrchardBundle().GetAnchor(), tree)) {
|
||||
auto txid = tx.GetHash().ToString();
|
||||
auto anchor = tx.GetOrchardBundle().GetAnchor().ToString();
|
||||
TracingWarn("consensus", "Transaction uses unknown Orchard anchor",
|
||||
"txid", txid.c_str(),
|
||||
"anchor", anchor.c_str());
|
||||
return UnsatisfiedShieldedReq::OrchardUnknownAnchor;
|
||||
std::optional<uint256> root = tx.GetOrchardBundle().GetAnchor();
|
||||
if (root) {
|
||||
OrchardMerkleTree tree;
|
||||
if (!GetOrchardAnchorAt(root.value(), tree)) {
|
||||
auto txid = tx.GetHash().ToString();
|
||||
auto anchor = root.value().ToString();
|
||||
TracingWarn("consensus", "Transaction uses unknown Orchard anchor",
|
||||
"txid", txid.c_str(),
|
||||
"anchor", anchor.c_str());
|
||||
return UnsatisfiedShieldedReq::OrchardUnknownAnchor;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
|
|
@ -100,12 +100,12 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
const uint256 GetAnchor() const {
|
||||
const std::optional<uint256> GetAnchor() const {
|
||||
uint256 result;
|
||||
if (orchard_bundle_anchor(inner.get(), result.begin())) {
|
||||
return result;
|
||||
} else {
|
||||
throw std::runtime_error("cannot obtain Orchard anchor from empty bundle");
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue