Contracts: make_outputs takes nanogrin amounts (Vec<u64>), not a string

OutputSelectionArgs.make_outputs was a comma-separated grin string parsed inside
libwallet via amount_from_hr_string. Move that parsing to the CLI boundary and
carry explicit nanogrin u64 amounts through the API and Context instead:
- OutputSelectionArgs.make_outputs: Option<String> -> Option<Vec<u64>>;
  output_amounts() becomes a plain accessor, num_custom_outputs() uses len().
- The CLI (wallet_args) parses grin -> nanogrin per amount; ContractNewArgs and
  ContractSetupArgs carry Vec<u64> and copy it through.
- Update the two tests that supplied make_outputs as a string.

Addresses PR #754 review (types.rs, wallet_args.rs).
This commit is contained in:
jwinterm
2026-06-10 14:18:50 -04:00
parent 3fba1319fb
commit f13ea7f01f
5 changed files with 33 additions and 45 deletions
@@ -58,7 +58,14 @@ fn contract_self_spend_custom_tx_impl(test_dir: &'static str) -> Result<(), libw
let selection_args = OutputSelectionArgs {
min_input_confirmation: 0,
use_inputs: Some(use_inputs.clone()), // we will use two coinbase inputs
make_outputs: Some(String::from("88,35,3,0.2,15")), // the sum is such that it will need to pick another input making total of 3 inputs
// the sum is such that it will need to pick another input making total of 3 inputs
make_outputs: Some(vec![
88 * consensus::GRIN_BASE,
35 * consensus::GRIN_BASE,
3 * consensus::GRIN_BASE,
(0.2 * consensus::GRIN_BASE as f64) as u64,
15 * consensus::GRIN_BASE,
]),
};
wallet::controller::owner_single_use(Some(send_wallet.clone()), send_mask, None, |api, m| {
// Send wallet inititates a standard transaction with --send=0