From d4d5f97bd8381ff1cd6c7154ec0787ec6e845e7b Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sun, 7 Jun 2026 16:14:02 -0400 Subject: [PATCH] Contracts: validate net_change in the foreign sign path The foreign contract_sign API unwrapped the optional net_change field, so an incomplete request could panic the wallet. Return an error instead, matching the foreign contract_new path. Addresses PR #754 review (foreign.rs). --- libwallet/src/api_impl/foreign.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libwallet/src/api_impl/foreign.rs b/libwallet/src/api_impl/foreign.rs index bf9308c..e8a8e8c 100644 --- a/libwallet/src/api_impl/foreign.rs +++ b/libwallet/src/api_impl/foreign.rs @@ -276,7 +276,9 @@ where C: NodeClient + 'a, K: Keychain + 'a, { - let net_change = args.net_change.unwrap(); + let net_change = args.net_change.ok_or_else(|| { + Error::GenericError("Contract requires a net change (--send or --receive)".to_string()) + })?; if net_change <= 0 { return Err(Error::GenericError( "Can't sign a non-receiving contract from a foreign API.".to_string(),