Simplify api commits (#3423)

* simplify api with unspent by commitment

* fix chain tests
This commit is contained in:
Antioch Peverell
2020-08-17 18:19:29 +01:00
committed by GitHub
parent d1b90f89a0
commit 599bf22cfc
6 changed files with 41 additions and 51 deletions
+5 -3
View File
@@ -291,7 +291,7 @@ impl OutputPrintable {
};
let out_id = core::OutputIdentifier::from(output);
let pos = chain.get_unspent(&out_id)?;
let pos = chain.get_unspent(out_id.commitment())?;
let spent = pos.is_none();
@@ -301,8 +301,10 @@ impl OutputPrintable {
// api is currently doing the right thing here:
// An output can be spent and then subsequently reused and the new instance unspent.
// This would result in a height that differs from the provided block height.
let output_pos = pos.map(|x| x.pos).unwrap_or(0);
let block_height = pos.map(|x| x.height).or(block_header.map(|x| x.height));
let output_pos = pos.map(|(_, x)| x.pos).unwrap_or(0);
let block_height = pos
.map(|(_, x)| x.height)
.or(block_header.map(|x| x.height));
let proof = if include_proof {
Some(output.proof_bytes().to_hex())