Skip to content

Commit 79b9405

Browse files
authored
Merge pull request zingolabs#1842 from Oscar-Pepper/improve_spendable_with_new_blocks
increase min confirmations to 3
2 parents 965d285 + e48df68 commit 79b9405

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

zingocli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub fn startup(
466466
transparent_address_discovery: TransparentAddressDiscovery::minimal(),
467467
performance_level: PerformanceLevel::High,
468468
},
469-
min_confirmations: NonZeroU32::try_from(1).unwrap(),
469+
min_confirmations: NonZeroU32::try_from(3).unwrap(),
470470
},
471471
1.try_into().unwrap(),
472472
)

zingolib/src/commands.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use std::collections::HashMap;
55
use std::convert::TryInto;
6+
use std::num::NonZeroU32;
67
use std::str::FromStr;
78

89
use indoc::indoc;
@@ -1621,8 +1622,11 @@ impl Command for SettingsCommand {
16211622
If there are no arguments the full list of current settings will be shown.
16221623
To set, pass the setting as an argument followed by the value.
16231624
1625+
Minimum confirmations must be 1 or greater.
1626+
16241627
Settings:
16251628
performance [ low | medium | high | maximum ]
1629+
min_confirmations 3
16261630
16271631
Usage:
16281632
settings
@@ -1643,8 +1647,10 @@ impl Command for SettingsCommand {
16431647
return format!(
16441648
r#"
16451649
performance: {}
1650+
min confirmations: {}
16461651
"#,
1647-
wallet.wallet_settings.sync_config.performance_level
1652+
wallet.wallet_settings.sync_config.performance_level,
1653+
wallet.wallet_settings.min_confirmations,
16481654
);
16491655
}
16501656

@@ -1654,15 +1660,33 @@ performance: {}
16541660
"medium" => wallet.wallet_settings.sync_config.performance_level = PerformanceLevel::Medium,
16551661
"high" => wallet.wallet_settings.sync_config.performance_level = PerformanceLevel::High,
16561662
"maximum" => wallet.wallet_settings.sync_config.performance_level = PerformanceLevel::Maximum,
1657-
_ => {
1658-
return "Error: invalid arguments\nTry 'help settings' for correct usage and examples"
1659-
.to_string();}
1660-
},
1663+
_ => {
1664+
return "Error: invalid arguments\nTry 'help settings' for correct usage and examples"
1665+
.to_string();}
1666+
},
1667+
"min_confirmations" => {
1668+
let min_confirmations = match args[1].parse::<u32>() {
1669+
Ok(m) => match NonZeroU32::try_from(m) {
1670+
Ok(m) => m,
1671+
Err(_) => {
1672+
return "Error: invalid arguments\nTry 'help settings' for correct usage and examples"
1673+
.to_string();
1674+
}
1675+
},
1676+
Err(_) => {
1677+
return "Error: invalid arguments\nTry 'help settings' for correct usage and examples"
1678+
.to_string();
1679+
}
1680+
};
1681+
wallet.wallet_settings.min_confirmations = min_confirmations
1682+
}
16611683
_ => {
16621684
return "Error: invalid arguments\nTry 'help settings' for correct usage and examples"
16631685
.to_string();}
16641686
}
16651687

1688+
wallet.save_required = true;
1689+
16661690
"Successfully updated settings.".to_string()
16671691
})
16681692
}

zingolib/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl Default for ZingoConfigBuilder {
251251
pepper_sync::config::TransparentAddressDiscovery::minimal(),
252252
performance_level: pepper_sync::config::PerformanceLevel::High,
253253
},
254-
min_confirmations: NonZeroU32::try_from(1).unwrap(),
254+
min_confirmations: NonZeroU32::try_from(3).unwrap(),
255255
},
256256
no_of_accounts: NonZeroU32::try_from(1).expect("hard coded non-zero integer"),
257257
}

zingolib/src/wallet/disk.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl LightWallet {
338338
transparent_address_discovery: TransparentAddressDiscovery::minimal(),
339339
performance_level: PerformanceLevel::High,
340340
},
341-
min_confirmations: NonZeroU32::try_from(1).unwrap(),
341+
min_confirmations: NonZeroU32::try_from(3).unwrap(),
342342
},
343343
};
344344

@@ -527,7 +527,7 @@ impl LightWallet {
527527
NonZeroU32::try_from(reader.read_u32::<LittleEndian>()?)
528528
.expect("only valid non-zero u32s stored")
529529
} else {
530-
NonZeroU32::try_from(1).expect("only valid non-zero u32s stored")
530+
NonZeroU32::try_from(3).expect("only valid non-zero u32s stored")
531531
},
532532
}
533533
} else {
@@ -536,7 +536,7 @@ impl LightWallet {
536536
transparent_address_discovery: TransparentAddressDiscovery::minimal(),
537537
performance_level: PerformanceLevel::High,
538538
},
539-
min_confirmations: NonZeroU32::try_from(1).unwrap(),
539+
min_confirmations: NonZeroU32::try_from(3).unwrap(),
540540
}
541541
};
542542

zingolib/src/wallet/propose.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! creating proposals from wallet data
22
3-
use std::num::NonZeroU32;
4-
53
use zcash_client_backend::{
64
data_api::wallet::input_selection::GreedyInputSelector,
75
fees::{DustAction, DustOutputPolicy},
@@ -59,8 +57,7 @@ impl LightWallet {
5957
&input_selector,
6058
&change_strategy,
6159
request,
62-
// TODO: update anchor height selection
63-
NonZeroU32::MIN,
60+
self.wallet_settings.min_confirmations,
6461
)
6562
.map_err(ProposeSendError::Proposal)
6663
}

0 commit comments

Comments
 (0)