Skip to content

Commit

Permalink
Merge pull request #160 from RGB-WG/fix/66
Browse files Browse the repository at this point in the history
Fix invalid anchor resolution for seals
  • Loading branch information
dr-orlovsky authored Jun 16, 2023
2 parents 7e526fc + 08f37ae commit f387157
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/validation/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ pub enum Warning {
ExcessiveOperation(OpId),
/// terminal witness transaction {0} is not yet mined.
TerminalWitnessNotMined(Txid),
/// anchor for operation {0} is not found in the index. This is possible an
/// internal bug of RGB Core library.
AnchorNotFound(OpId),

/// Custom warning by external services on top of RGB Core.
#[display(inner)]
Expand Down
16 changes: 9 additions & 7 deletions src/validation/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::collections::{BTreeMap, BTreeSet, VecDeque};

use bp::dbc::Anchor;
use bp::seals::txout::Witness;
use bp::seals::txout::{TxPtr, Witness};
use bp::{Tx, Txid};
use commit_verify::mpc;
use single_use_seals::SealWitness;
Expand Down Expand Up @@ -411,15 +411,17 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx>
continue
};

match self.anchor_index.get(&op) {
Some(anchor) => {
let seal = match (seal.txid, self.anchor_index.get(&op)) {
(TxPtr::WitnessTx, Some(anchor)) => {
let prev_witness_txid = anchor.txid;
seals.push(seal.resolve(prev_witness_txid))
seal.resolve(prev_witness_txid)
}
None => {
self.status.add_warning(Warning::AnchorNotFound(op));
(TxPtr::WitnessTx, None) => {
panic!("anchor for the operation {op} was not indexed by the validator");
}
}
(TxPtr::Txid(txid), _) => seal.resolve(txid),
};
seals.push(seal)
}

let message = mpc::Message::from(bundle_id);
Expand Down

0 comments on commit f387157

Please sign in to comment.