Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 39b41bb

Browse files
authored
Merge pull request #76 from AshAvalanche/create-subnet-control-keys
feat(wallet): create_subnet ctrl keys + threshold
2 parents 20c6156 + f135a9b commit 39b41bb

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/wallet/p/create_subnet.rs

+22-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ where
1616
{
1717
pub inner: crate::wallet::p::P<T>,
1818

19+
/// In order to add a validator to this Subnet, threshold signatures are required from the addresses in controlKeys
20+
pub control_keys: Vec<ids::short::Id>,
21+
pub threshold: u32,
22+
1923
/// Set "true" to poll transaction status after issuance for its acceptance.
2024
pub check_acceptance: bool,
2125

@@ -37,6 +41,8 @@ where
3741
pub fn new(p: &crate::wallet::p::P<T>) -> Self {
3842
Self {
3943
inner: p.clone(),
44+
control_keys: vec![p.inner.short_address.clone()],
45+
threshold: 1,
4046
check_acceptance: false,
4147
poll_initial_wait: Duration::from_millis(1500),
4248
poll_interval: Duration::from_secs(1),
@@ -45,6 +51,20 @@ where
4551
}
4652
}
4753

54+
/// Sets the control keys.
55+
#[must_use]
56+
pub fn control_keys(mut self, control_keys: Vec<ids::short::Id>) -> Self {
57+
self.control_keys = control_keys;
58+
self
59+
}
60+
61+
/// Sets the threshold.
62+
#[must_use]
63+
pub fn threshold(mut self, threshold: u32) -> Self {
64+
self.threshold = threshold;
65+
self
66+
}
67+
4868
/// Sets the check acceptance boolean flag.
4969
#[must_use]
5070
pub fn check_acceptance(mut self, check_acceptance: bool) -> Self {
@@ -100,8 +120,8 @@ where
100120
},
101121
owner: key::secp256k1::txs::OutputOwners {
102122
locktime: 0,
103-
threshold: 1,
104-
addresses: vec![self.inner.inner.short_address.clone()],
123+
threshold: self.threshold,
124+
addresses: self.control_keys.clone(),
105125
},
106126
..Default::default()
107127
};

0 commit comments

Comments
 (0)