From 1d89ec2682dccae334fc71391dee53af3a31b24a Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sun, 7 Jun 2026 19:10:22 -0400 Subject: [PATCH] Contracts: report agreed_net_change in contract view contract view hardcoded agreed_net_change to None. When a local context exists we've agreed on the net change, so read it from the context and report it (None when there's no context); other errors propagate. Addresses PR #754 review (view.rs). --- libwallet/src/contract/actions/view.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libwallet/src/contract/actions/view.rs b/libwallet/src/contract/actions/view.rs index a28885e..63e270b 100644 --- a/libwallet/src/contract/actions/view.rs +++ b/libwallet/src/contract/actions/view.rs @@ -23,8 +23,8 @@ use crate::types::{NodeClient, WalletBackend}; /// View contract pub fn view<'a, T: ?Sized, C, K>( - _w: &mut T, - _keychain_mask: Option<&SecretKey>, + w: &mut T, + keychain_mask: Option<&SecretKey>, slate: &mut Slate, _encrypted_for: &str, ) -> Result @@ -55,12 +55,19 @@ where .filter(|v| !v.is_complete()) .count(); + // If we have a local context for this slate we've agreed on a net change; surface it. + let agreed_net_change = match w.get_private_context(keychain_mask, slate.id.as_bytes()) { + Ok(ctx) => Some(ctx.get_net_change()), + Err(Error::NotFoundErr(_)) => None, + Err(e) => return Err(e), + }; + // TODO: Maybe we can know if the slate was meant for us if it was encrypted for us. // A possible issue is that one can encrypt the same slate for 10 people. let ct_view = ContractView { num_participants: slate.num_participants, suggested_net_change: suggested_net_change, - agreed_net_change: None, // TODO + agreed_net_change, num_sigs: num_sigs as u8, is_executed: is_executed, ..Default::default()