Represent RCT amounts with None, not 0.

Fixes #282.

Does allow any v1 TXs which exist, and v2 miner-TXs, to specify Some(0). As far
as I can tell, both were/are theoreitcally possible.
This commit is contained in:
Luke Parker
2023-06-29 13:16:51 -04:00
parent ac708b3b2a
commit a95ecc2512
4 changed files with 55 additions and 28 deletions

View File

@@ -184,7 +184,7 @@ async fn prepare_inputs<R: RngCore + CryptoRng, RPC: RpcConnection>(
));
tx.prefix.inputs.push(Input::ToKey {
amount: 0,
amount: None,
key_offsets: decoys[i].offsets.clone(),
key_image: signable[i].1,
});
@@ -633,7 +633,7 @@ impl SignableTransaction {
for output in &outputs {
fee -= output.commitment.amount;
tx_outputs.push(Output {
amount: 0,
amount: None,
key: output.dest.compress(),
view_tag: Some(output.view_tag).filter(|_| matches!(self.protocol, Protocol::v16)),
});
@@ -691,7 +691,7 @@ impl SignableTransaction {
uniqueness(
&images
.iter()
.map(|image| Input::ToKey { amount: 0, key_offsets: vec![], key_image: *image })
.map(|image| Input::ToKey { amount: None, key_offsets: vec![], key_image: *image })
.collect::<Vec<_>>(),
),
);
@@ -750,7 +750,7 @@ impl Eventuality {
for (o, (expected, actual)) in outputs.iter().zip(tx.prefix.outputs.iter()).enumerate() {
// Verify the output, commitment, and encrypted amount.
if (&Output {
amount: 0,
amount: None,
key: expected.dest.compress(),
view_tag: Some(expected.view_tag).filter(|_| matches!(self.protocol, Protocol::v16)),
} != actual) ||