From 7bd69374af3abe651c9e882d412d4078bfad6f60 Mon Sep 17 00:00:00 2001 From: wiesche Date: Fri, 4 Sep 2026 21:00:37 +0200 Subject: [PATCH] document contract account binding --- controller/tests/contract_accounts_switch.rs | 2 +- doc/contracts.md | 3 +++ libwallet/src/contract/actions/README.md | 2 -- libwallet/src/contract/types.rs | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/controller/tests/contract_accounts_switch.rs b/controller/tests/contract_accounts_switch.rs index 1f44ede..889bfb7 100644 --- a/controller/tests/contract_accounts_switch.rs +++ b/controller/tests/contract_accounts_switch.rs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Test a wallet doing contracts with different accounts and switching between them +//! Test that a contract stays with its original account after switching accounts // #[macro_use] extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; diff --git a/doc/contracts.md b/doc/contracts.md index 16cbf20..4748c5a 100644 --- a/doc/contracts.md +++ b/doc/contracts.md @@ -38,6 +38,9 @@ is used for the fee estimate, so any required inputs need enough confirmations a A value of `0` allows unconfirmed non-coinbase outputs. Open contracts do not reserve funds, so a late-locked contract can fail if another transaction spends the available outputs first. +Each side's account is fixed when it first joins the contract. Changing the active account +later does not affect setup or signing; they use the account stored in the context. + ## View and revoke `view` reads a slate or Slatepack and shows its inputs and outputs when present, fees, diff --git a/libwallet/src/contract/actions/README.md b/libwallet/src/contract/actions/README.md index 69be66a..bd39455 100644 --- a/libwallet/src/contract/actions/README.md +++ b/libwallet/src/contract/actions/README.md @@ -62,8 +62,6 @@ Separating side effects until the 'save_step' part would make these functions mu - Add full API and RPC examples once the contract interface is stable. - Separate side effects out from the computation, as described above. - Store transactions in LMDB so they can be committed with the wallet state. - - Decide whether `contract_accounts_switch.rs` is a legitimate scenario, or whether - signing under a different account than setup should error. ### Side-effects diff --git a/libwallet/src/contract/types.rs b/libwallet/src/contract/types.rs index cc612f9..a0f7689 100644 --- a/libwallet/src/contract/types.rs +++ b/libwallet/src/contract/types.rs @@ -118,6 +118,7 @@ pub struct ContractSetupArgsAPI { /// The human readable account name from which to draw outputs /// for the transaction, overriding whatever the active account is as set via the /// [`set_active_account`](../grin_wallet_api/owner/struct.Owner.html#method.set_active_account) method. + /// Only used when creating the local contract context pub src_acct_name: Option, /// The net change we will agree on. The amount is in nanogrins (`1 G = 1_000_000_000nG`). /// The value is positive when we are on the receiving end and negative when we are the sender.