Skip to content

Commit aa8c8f9

Browse files
committed
update AddressInfo struct
1 parent 3e4678d commit aa8c8f9

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

src/wallet/mod.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ pub struct AddressInfo {
140140
pub index: u32,
141141
/// Address
142142
pub address: Address,
143+
/// Type of keychain
144+
pub keychain: KeychainKind,
143145
}
144146

145147
impl Deref for AddressInfo {
@@ -246,6 +248,7 @@ where
246248
.map(|address| AddressInfo {
247249
address,
248250
index: incremented_index,
251+
keychain,
249252
})
250253
.map_err(|_| Error::ScriptDoesntHaveAddressForm)
251254
}
@@ -276,6 +279,7 @@ where
276279
.map(|address| AddressInfo {
277280
address,
278281
index: current_index,
282+
keychain,
279283
})
280284
.map_err(|_| Error::ScriptDoesntHaveAddressForm)
281285
}
@@ -286,7 +290,11 @@ where
286290
self.get_descriptor_for_keychain(keychain)
287291
.as_derived(index, &self.secp)
288292
.address(self.network)
289-
.map(|address| AddressInfo { index, address })
293+
.map(|address| AddressInfo {
294+
index,
295+
address,
296+
keychain,
297+
})
290298
.map_err(|_| Error::ScriptDoesntHaveAddressForm)
291299
}
292300

@@ -298,7 +306,11 @@ where
298306
self.get_descriptor_for_keychain(keychain)
299307
.as_derived(index, &self.secp)
300308
.address(self.network)
301-
.map(|address| AddressInfo { index, address })
309+
.map(|address| AddressInfo {
310+
index,
311+
address,
312+
keychain,
313+
})
302314
.map_err(|_| Error::ScriptDoesntHaveAddressForm)
303315
}
304316

@@ -3917,6 +3929,7 @@ pub(crate) mod test {
39173929
AddressInfo {
39183930
index: 0,
39193931
address: Address::from_str("tb1q6yn66vajcctph75pvylgkksgpp6nq04ppwct9a").unwrap(),
3932+
keychain: KeychainKind::External,
39203933
}
39213934
);
39223935

@@ -3925,7 +3938,8 @@ pub(crate) mod test {
39253938
wallet.get_address(New).unwrap(),
39263939
AddressInfo {
39273940
index: 1,
3928-
address: Address::from_str("tb1q4er7kxx6sssz3q7qp7zsqsdx4erceahhax77d7").unwrap()
3941+
address: Address::from_str("tb1q4er7kxx6sssz3q7qp7zsqsdx4erceahhax77d7").unwrap(),
3942+
keychain: KeychainKind::External,
39293943
}
39303944
);
39313945

@@ -3934,7 +3948,8 @@ pub(crate) mod test {
39343948
wallet.get_address(Peek(25)).unwrap(),
39353949
AddressInfo {
39363950
index: 25,
3937-
address: Address::from_str("tb1qsp7qu0knx3sl6536dzs0703u2w2ag6ppl9d0c2").unwrap()
3951+
address: Address::from_str("tb1qsp7qu0knx3sl6536dzs0703u2w2ag6ppl9d0c2").unwrap(),
3952+
keychain: KeychainKind::External,
39383953
}
39393954
);
39403955

@@ -3943,7 +3958,8 @@ pub(crate) mod test {
39433958
wallet.get_address(New).unwrap(),
39443959
AddressInfo {
39453960
index: 2,
3946-
address: Address::from_str("tb1qzntf2mqex4ehwkjlfdyy3ewdlk08qkvkvrz7x2").unwrap()
3961+
address: Address::from_str("tb1qzntf2mqex4ehwkjlfdyy3ewdlk08qkvkvrz7x2").unwrap(),
3962+
keychain: KeychainKind::External,
39473963
}
39483964
);
39493965

@@ -3952,7 +3968,8 @@ pub(crate) mod test {
39523968
wallet.get_address(Reset(1)).unwrap(),
39533969
AddressInfo {
39543970
index: 1,
3955-
address: Address::from_str("tb1q4er7kxx6sssz3q7qp7zsqsdx4erceahhax77d7").unwrap()
3971+
address: Address::from_str("tb1q4er7kxx6sssz3q7qp7zsqsdx4erceahhax77d7").unwrap(),
3972+
keychain: KeychainKind::External,
39563973
}
39573974
);
39583975

@@ -3961,7 +3978,8 @@ pub(crate) mod test {
39613978
wallet.get_address(New).unwrap(),
39623979
AddressInfo {
39633980
index: 2,
3964-
address: Address::from_str("tb1qzntf2mqex4ehwkjlfdyy3ewdlk08qkvkvrz7x2").unwrap()
3981+
address: Address::from_str("tb1qzntf2mqex4ehwkjlfdyy3ewdlk08qkvkvrz7x2").unwrap(),
3982+
keychain: KeychainKind::External,
39653983
}
39663984
);
39673985
}

0 commit comments

Comments
 (0)