Refactor Output Identifiers (#3371)

* refactor output to have internal output identifier

refactor to use AsRef for output identifier

make the output MMR explicit in terms of output identifiers

* put the serde deser back for rangeproof

* add json test for transactions
This commit is contained in:
Antioch Peverell
2020-09-03 10:59:54 +01:00
committed by GitHub
parent caa6b8c747
commit 133089e985
17 changed files with 198 additions and 154 deletions
+2 -2
View File
@@ -246,7 +246,7 @@ impl OutputHandler {
let outputs = block
.outputs()
.iter()
.filter(|output| commitments.is_empty() || commitments.contains(&output.commit))
.filter(|output| commitments.is_empty() || commitments.contains(&output.commitment()))
.map(|output| {
OutputPrintable::from_output(output, &chain, Some(&header), include_proof, true)
})
@@ -279,7 +279,7 @@ impl OutputHandler {
let outputs = block
.outputs()
.iter()
.filter(|output| commitments.is_empty() || commitments.contains(&output.commit))
.filter(|output| commitments.is_empty() || commitments.contains(&output.commitment()))
.map(|output| {
OutputPrintable::from_output(
output,
+3 -4
View File
@@ -290,8 +290,7 @@ impl OutputPrintable {
OutputType::Transaction
};
let out_id = core::OutputIdentifier::from(output);
let pos = chain.get_unspent(out_id.commitment())?;
let pos = chain.get_unspent(output.commitment())?;
let spent = pos.is_none();
@@ -319,13 +318,13 @@ impl OutputPrintable {
let mut merkle_proof = None;
if include_merkle_proof && output.is_coinbase() && !spent {
if let Some(block_header) = block_header {
merkle_proof = chain.get_merkle_proof(&out_id, &block_header).ok();
merkle_proof = chain.get_merkle_proof(output, &block_header).ok();
}
};
Ok(OutputPrintable {
output_type,
commit: output.commit,
commit: output.commitment(),
spent,
proof,
proof_hash: output.proof.hash().to_hex(),