diff --git a/cli/src/command.rs b/cli/src/command.rs index da4f318..61f2ab4 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -1246,7 +1246,7 @@ impl Exec for RgbArgs { Command::Validate { file } => { let mut resolver = self.resolver()?; let consignment = Transfer::load_file(file)?; - resolver.add_terminals(&consignment); + resolver.add_consignment_txes(&consignment); let status = match consignment.validate(&resolver, self.chain_net()) { Ok(consignment) => consignment.into_validation_status(), Err((status, _)) => status, @@ -1262,7 +1262,7 @@ impl Exec for RgbArgs { let mut stock = self.rgb_stock()?; let mut resolver = self.resolver()?; let transfer = Transfer::load_file(file)?; - resolver.add_terminals(&transfer); + resolver.add_consignment_txes(&transfer); let valid = transfer .validate(&resolver, self.chain_net()) .map_err(|(status, _)| status)?; diff --git a/src/indexers/any.rs b/src/indexers/any.rs index 5bc6e09..b40c952 100644 --- a/src/indexers/any.rs +++ b/src/indexers/any.rs @@ -43,7 +43,7 @@ pub trait RgbResolver: Send { #[non_exhaustive] pub struct AnyResolver { inner: Box, - terminal_txes: HashMap, + consignment_txes: HashMap, } impl AnyResolver { @@ -54,7 +54,7 @@ impl AnyResolver { electrum::Client::from_config(url, config.unwrap_or_default()) .map_err(|e| e.to_string())?, ), - terminal_txes: Default::default(), + consignment_txes: Default::default(), }) } @@ -65,7 +65,7 @@ impl AnyResolver { esplora::BlockingClient::from_config(url, config.unwrap_or_default()) .map_err(|e| e.to_string())?, ), - terminal_txes: Default::default(), + consignment_txes: Default::default(), }) } @@ -76,7 +76,7 @@ impl AnyResolver { url, config.unwrap_or_default(), )?), - terminal_txes: Default::default(), + consignment_txes: Default::default(), }) } @@ -84,8 +84,12 @@ impl AnyResolver { self.inner.check_chain_net(chain_net) } - pub fn add_terminals(&mut self, consignment: &Consignment) { - self.terminal_txes.extend( + /// Add to the resolver the TXs found in the consignment bundles. Those TXs + /// will not be resolved by an indexer and will be considered tentative. + /// Use with caution, this could allow accepting a consignment containing TXs that have not + /// been broadcasted. + pub fn add_consignment_txes(&mut self, consignment: &Consignment) { + self.consignment_txes.extend( consignment .bundles .iter() @@ -97,7 +101,7 @@ impl AnyResolver { impl ResolveWitness for AnyResolver { fn resolve_pub_witness(&self, witness_id: Txid) -> Result { - if let Some(tx) = self.terminal_txes.get(&witness_id) { + if let Some(tx) = self.consignment_txes.get(&witness_id) { return Ok(tx.clone()); } @@ -111,7 +115,7 @@ impl ResolveWitness for AnyResolver { &self, witness_id: Txid, ) -> Result { - if self.terminal_txes.contains_key(&witness_id) { + if self.consignment_txes.contains_key(&witness_id) { return Ok(WitnessOrd::Tentative); }