Skip to content

Commit

Permalink
grin output_identifier refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Sep 1, 2020
1 parent 24f35a2 commit 2b1ba14
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
5 changes: 3 additions & 2 deletions impls/src/test_framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ fn get_output_local(chain: &chain::Chain, commit: pedersen::Commitment) -> Optio
if chain.get_unspent(commit).unwrap().is_some() {
let block_height = chain.get_header_for_output(commit).unwrap().height;
let output_pos = chain.get_output_pos(&commit).unwrap_or(0);
return Some(api::Output::new(&commit, block_height, output_pos));
Some(api::Output::new(&commit, block_height, output_pos))
} else {
None
}
None
}

/// Get a kernel from the chain locally
Expand Down
2 changes: 1 addition & 1 deletion libwallet/src/internal/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ mod test {
.unwrap();

let inputs: Vec<Input> = tx2.inputs().into();
assert_eq!(tx1.outputs()[0].features, inputs[0].features);
assert_eq!(tx1.outputs()[0].features(), inputs[0].features);
assert_eq!(tx1.outputs()[0].commitment(), inputs[0].commitment());
}

Expand Down
16 changes: 5 additions & 11 deletions libwallet/src/slate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,8 @@ impl From<&Slate> for Option<Vec<CommitsV4>> {
}
for o in outs.iter() {
ret_vec.push(CommitsV4 {
f: o.features.into(),
c: o.commit,
f: o.features().into(),
c: o.commitment(),
p: Some(o.proof),
});
}
Expand Down Expand Up @@ -1020,14 +1020,8 @@ pub fn tx_from_slate_v4(slate: &SlateV4) -> Option<Transaction> {
let mut tx = Transaction::empty().with_kernel(kernel);

for c in coms.iter() {
match &c.p {
Some(p) => {
tx = tx.with_output(Output {
features: c.f.into(),
commit: c.c,
proof: p.clone(),
})
}
match c.p {
Some(p) => tx = tx.with_output(Output::new(c.f.into(), c.c, p)),
None => {
tx = tx.with_input(Input {
features: c.f.into(),
Expand All @@ -1036,7 +1030,7 @@ pub fn tx_from_slate_v4(slate: &SlateV4) -> Option<Transaction> {
}
}
}
tx.offset = slate.off.clone();
tx = tx.with_offset(slate.off.clone());
Some(tx)
}

Expand Down
4 changes: 2 additions & 2 deletions libwallet/src/slate_versions/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ impl From<&Output> for CbOutputV4 {
fn from(output: &Output) -> CbOutputV4 {
CbOutputV4 {
features: CbOutputFeatures::Coinbase,
commit: output.commit,
proof: output.proof,
commit: output.commitment(),
proof: output.proof(),
}
}
}
Expand Down

0 comments on commit 2b1ba14

Please sign in to comment.