mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Wallet recovery return unspent only (#340)
* beginning to add wallet restore... api endpoints and basic restore * basic restore working, still missing features * rustfmt * large speed up to output search, should be more or less working * properly mark coinbase status * ensure only unspent utxos are returned from sumtree
This commit is contained in:
parent
e20975136e
commit
6ad403fbf8
2 changed files with 8 additions and 1 deletions
|
@ -118,7 +118,8 @@ impl UtxoHandler {
|
|||
let outputs = block
|
||||
.outputs
|
||||
.iter()
|
||||
.map(|k| OutputSwitch::from_output(k, &header))
|
||||
.filter(|c|self.chain.is_unspent(&c.commit).unwrap())
|
||||
.map(|k|OutputSwitch::from_output(k, &header))
|
||||
.collect();
|
||||
BlockOutputs {
|
||||
header: BlockHeaderInfo::from_header(&header),
|
||||
|
|
|
@ -239,6 +239,12 @@ impl Chain {
|
|||
}
|
||||
}
|
||||
|
||||
/// Checks whether an output is unspent
|
||||
pub fn is_unspent(&self, output_ref: &Commitment) -> Result<bool, Error> {
|
||||
let sumtrees = self.sumtrees.read().unwrap();
|
||||
sumtrees.is_unspent(output_ref)
|
||||
}
|
||||
|
||||
/// Sets the sumtree roots on a brand new block by applying the block on the
|
||||
/// current sumtree state.
|
||||
pub fn set_sumtree_roots(&self, b: &mut Block) -> Result<(), Error> {
|
||||
|
|
Loading…
Reference in a new issue