mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-25 17:24:47 -07:00
rpc: init wrapper crate + global: snapshot
This commit is contained in:
@@ -30,7 +30,7 @@ pub struct ByAddressType<T> {
|
||||
}
|
||||
|
||||
impl<T> ByAddressType<T> {
|
||||
pub fn new<F>(f: F) -> Result<Self>
|
||||
pub fn new_with_name<F>(f: F) -> Result<Self>
|
||||
where
|
||||
F: Fn(&'static str) -> Result<T>,
|
||||
{
|
||||
@@ -46,6 +46,22 @@ impl<T> ByAddressType<T> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_with_index<F>(f: F) -> Result<Self>
|
||||
where
|
||||
F: Fn(usize) -> Result<T>,
|
||||
{
|
||||
Ok(Self {
|
||||
p2pk65: f(0)?,
|
||||
p2pk33: f(1)?,
|
||||
p2pkh: f(2)?,
|
||||
p2sh: f(3)?,
|
||||
p2wpkh: f(4)?,
|
||||
p2wsh: f(5)?,
|
||||
p2tr: f(6)?,
|
||||
p2a: f(7)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_unwrap(&self, address_type: OutputType) -> &T {
|
||||
self.get(address_type).unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user