diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index cf43605..7764789 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -616,7 +616,7 @@ where sender_address: p.sender_address, timestamp: p.timestamp.unwrap().timestamp(), memo: p.memo, - promise_signature: p.promise_signature, + promise_signature: p.receiver_signature, witness_data: None, }, p.sender_part_sig.unwrap(), diff --git a/libwallet/src/contract/actions/README.md b/libwallet/src/contract/actions/README.md index c4a1381..931cc59 100644 --- a/libwallet/src/contract/actions/README.md +++ b/libwallet/src/contract/actions/README.md @@ -47,7 +47,6 @@ without a user confirmation step. - Expose the kernel feature constants from `grin_core` and reuse them here. - Move payment-proof handling onto `Slate` so it can be used outside contracts and versioned with the slate format - - Unify legacy and early payment-proof storage - Add compact Slatepack support for contracts - Keep Slate V5 experimental until the related RFCs are accepted - Add contract history, lookup and transport. diff --git a/libwallet/src/contract/utils.rs b/libwallet/src/contract/utils.rs index 712d089..a17165e 100644 --- a/libwallet/src/contract/utils.rs +++ b/libwallet/src/contract/utils.rs @@ -126,21 +126,20 @@ where }; tx_log_entry.payment_proof = Some(StoredProofInfo { - receiver_address: p.receiver_address, - receiver_signature: p.promise_signature, - sender_address: sender_address.to_ed25519()?, - sender_address_path, - sender_signature: None, - // Filled as separate steps for now; could be merged into a general case - // once we know which nonces here belong to the recipient. proof_type: Some(p.proof_type.as_u8()), receiver_public_nonce: Some(recipient.public_nonce), receiver_public_excess: Some(recipient.public_blind_excess), timestamp: Some(timestamp), memo: p.memo.clone(), - promise_signature: p.promise_signature, sender_part_sig: sender.part_sig, sender_public_nonce, + ..StoredProofInfo::new( + p.receiver_address, + p.promise_signature, + sender_address.to_ed25519()?, + sender_address_path, + None, + ) }); } } diff --git a/libwallet/src/types.rs b/libwallet/src/types.rs index a4ef0a8..a07e79b 100644 --- a/libwallet/src/types.rs +++ b/libwallet/src/types.rs @@ -779,14 +779,14 @@ pub struct StoredProofInfo { #[serde(with = "dalek_ser::dalek_pubkey_serde")] pub receiver_address: DalekPublicKey, #[serde(with = "dalek_ser::option_dalek_sig_serde")] - /// receiver signature + /// Receiver signature for legacy proofs, or promise signature for early proofs pub receiver_signature: Option, /// sender address derivation path index pub sender_address_path: u32, /// sender address #[serde(with = "dalek_ser::dalek_pubkey_serde")] pub sender_address: DalekPublicKey, - /// sender signature + /// Legacy sender signature #[serde(with = "dalek_ser::option_dalek_sig_serde")] pub sender_signature: Option, // Fields beyond here are specific to early payment proofs @@ -800,10 +800,7 @@ pub struct StoredProofInfo { pub timestamp: Option>, /// Optional payment memo pub memo: Option, - /// recipient promise signature - #[serde(default, with = "dalek_ser::option_dalek_sig_serde")] - pub promise_signature: Option, - /// Original Sender partial key + /// Early-proof sender partial signature pub sender_part_sig: Option, /// Untweaked sender public nonce for a sender-nonce proof pub sender_public_nonce: Option, @@ -828,7 +825,6 @@ impl StoredProofInfo { receiver_public_excess: None, timestamp: None, memo: None, - promise_signature: None, sender_part_sig: None, sender_public_nonce: None, } @@ -1103,7 +1099,10 @@ mod tests { }); let proof: StoredProofInfo = serde_json::from_value(proof).unwrap(); - assert!(proof.promise_signature.is_none()); + assert!(proof.receiver_signature.is_none()); + let proof = serde_json::to_value(proof).unwrap(); + assert!(proof.get("receiver_signature").is_some()); + assert!(proof.get("promise_signature").is_none()); } #[test]