From 9838ac3d8d461113899304cf7f136eb1c68a4944 Mon Sep 17 00:00:00 2001 From: wiesche Date: Tue, 1 Sep 2026 19:48:37 +0200 Subject: [PATCH] fix invoice proof amount --- controller/tests/contract_early_proofs_rsr.rs | 1 + controller/tests/contract_early_proofs_srs.rs | 1 + libwallet/src/api_impl/owner.rs | 8 ++------ libwallet/src/contract/actions/README.md | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/controller/tests/contract_early_proofs_rsr.rs b/controller/tests/contract_early_proofs_rsr.rs index 87dbb6d..b05c783 100644 --- a/controller/tests/contract_early_proofs_rsr.rs +++ b/controller/tests/contract_early_proofs_rsr.rs @@ -213,6 +213,7 @@ fn contract_early_proofs_rsr_test_impl(test_dir: &'static str) -> Result<(), lib )?; let invoice_proof = invoice_proof.unwrap(); + assert_eq!(invoice_proof.amount, 5_000_000_000); let invoice_proof_json = serde_json::to_string(&invoice_proof).unwrap(); // Should have all proof fields filled out diff --git a/controller/tests/contract_early_proofs_srs.rs b/controller/tests/contract_early_proofs_srs.rs index 7875e92..344cb79 100644 --- a/controller/tests/contract_early_proofs_srs.rs +++ b/controller/tests/contract_early_proofs_srs.rs @@ -205,6 +205,7 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib )?; let invoice_proof = invoice_proof.unwrap(); + assert_eq!(invoice_proof.amount, 5_000_000_000); let invoice_proof_json = serde_json::to_string(&invoice_proof).unwrap(); // Should have all proof fields filled out diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index f9b0c05..9fdae60 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -569,12 +569,8 @@ where } // Pull out all needed fields, returning an error if they're not present let tx = txs.1[0].clone(); - let amount = if tx.amount_credited >= tx.amount_debited { - tx.amount_credited - tx.amount_debited - } else { - // TODO: Invoice proof not expecting fee included here - tx.amount_debited - tx.amount_credited - }; + // Contract tx logs store the agreed net change separately from the fee. + let amount = tx.amount_credited.abs_diff(tx.amount_debited); let (mut proof, sender_part_sig) = match tx.payment_proof { Some(p) => { diff --git a/libwallet/src/contract/actions/README.md b/libwallet/src/contract/actions/README.md index f0f91ab..795759e 100644 --- a/libwallet/src/contract/actions/README.md +++ b/libwallet/src/contract/actions/README.md @@ -56,7 +56,6 @@ Separating side effects until the 'save_step' part would make these functions mu - Distinguish the transfer amount from the fee-adjusted balance change in `view`. - Raise the replacement fee when `revoke` races a transaction already in the mempool. - Merge invoice-proof retrieval with the existing payment-proof API. - - Confirm that invoice-proof retrieval excludes the transaction fee from the amount. - Add a Grin node API for kernel lookup by MMR index, then use the witness index instead of searching by commitment. - Align the proof memo encoding with the early payment proofs proposal.