From aaeeadef3153e60e13d06c1df739a724ea025ffe Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 6 Jan 2025 11:37:03 +0100 Subject: [PATCH] iface: filter contract state basing on the witness mining status Closes #287 --- src/interface/contract.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/interface/contract.rs b/src/interface/contract.rs index 2709a054..545c4539 100644 --- a/src/interface/contract.rs +++ b/src/interface/contract.rs @@ -23,6 +23,7 @@ use std::borrow::Borrow; use std::collections::{BTreeSet, HashMap, HashSet}; use invoice::{Allocation, Amount}; +use rgb::vm::WitnessOrd; use rgb::{ AssignmentType, AttachState, ContractId, DataState, OpId, RevealedAttach, RevealedData, RevealedValue, Schema, VoidState, XOutpoint, XOutputSeal, XWitnessId, @@ -303,7 +304,15 @@ impl ContractIface { .ok_or(ContractError::FieldNameUnknown(name))?; Ok(state .into_iter() - .filter(move |outp| outp.opout.ty == type_id) + .filter(move |outp| { + outp.opout.ty == type_id + && outp + .witness + .and_then(|id| self.witness_info(id)) + // TODO: Check the mining depth + .map(|w| matches!(w.ord, WitnessOrd::Mined(_))) + .unwrap_or(true) + }) .cloned() .map(OutputAssignment::::transmute)) }