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).
This commit is contained in:
jwinterm
2026-06-07 16:14:02 -04:00
parent 502d2ae336
commit d4d5f97bd8
+3 -1
View File
@@ -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(),