add contract ttl

This commit is contained in:
wiesche
2026-09-05 10:06:00 +02:00
parent 97bd1ae08d
commit fb99cd6c9b
20 changed files with 246 additions and 18 deletions
+5 -2
View File
@@ -1690,14 +1690,16 @@ pub struct ContractNewArgs {
pub make_outputs: Option<Vec<u64>>,
/// Minimum number of confirmations required for an input
pub minimum_confirmations: u64,
/// Blocks until wallets should stop signing the contract
pub ttl_blocks: Option<u64>,
/// Select and lock outputs early
pub add_outputs: bool,
// Future features
/// Custom fee contribution
pub fee_rate: Option<u32>,
/// Save slatepack to a specific filename
pub outfile: Option<String>,
/// Select outputs early
pub add_outputs: bool,
}
impl ContractNewArgs {
@@ -1720,6 +1722,7 @@ impl ContractNewArgs {
fn to_api_args(&self) -> Result<ContractNewArgsAPI, Error> {
let net_change = self.get_net_change()?;
Ok(ContractNewArgsAPI {
ttl_blocks: self.ttl_blocks,
setup_args: ContractSetupArgsAPI {
src_acct_name: match self.src_acct_name.as_ref() {
Some(v) => Some(v.to_string()),
+10
View File
@@ -654,6 +654,11 @@ fn contract_view_table(
table.add_row(row![bFC->"Slate Id", bGC->slate.id]);
table.add_row(row![bFC->"State", bGC->slate.state]);
table.add_row(row![bFC->"Encrypted for This Wallet", bGC->yes_no(was_encrypted)]);
let deadline = match slate.ttl_cutoff_height {
0 => "None".to_string(),
height => height.to_string(),
};
table.add_row(row![bFC->"Signing Deadline Height", bGC->deadline]);
table.add_row(row![bFC->"Participants", bGC->view.num_participants]);
table.add_row(row![bFC->"Signatures", bGC->view.num_sigs]);
table.add_row(row![bFC->"Transfer Amount", bGC->amount_to_hr_string(slate.amount, false)]);
@@ -787,6 +792,7 @@ mod tests {
global::set_local_chain_type(global::ChainTypes::AutomatedTesting);
let mut slate = Slate::blank(2, false);
slate.amount = 1_000_000_000;
slate.ttl_cutoff_height = 42;
slate.fee_fields = FeeFields::new(0, 4_000_000).unwrap();
let input_commit = Commitment::from_vec(vec![3]);
let output_commit = Commitment::from_vec(vec![4]);
@@ -810,6 +816,7 @@ mod tests {
let table = contract_view_table(&slate, &view, true);
assert_eq!(table_value(&table, "Encrypted for This Wallet"), "Yes");
assert_eq!(table_value(&table, "Signing Deadline Height"), "42");
assert_eq!(table_value(&table, "Transfer Amount"), "1.000000000");
assert_eq!(
table_value(&table, "Current Transaction Fee"),
@@ -825,6 +832,9 @@ mod tests {
let table = contract_view_table(&slate, &view, false);
assert_eq!(table_value(&table, "Encrypted for This Wallet"), "No");
slate.ttl_cutoff_height = 0;
let table = contract_view_table(&slate, &view, false);
assert_eq!(table_value(&table, "Signing Deadline Height"), "None");
slate.tx = Some(Transaction::new(
Inputs::CommitOnly(vec![input_commit.into()]),