rpc: init wrapper crate + global: snapshot

This commit is contained in:
nym21
2025-10-20 23:06:25 +02:00
parent 9b230d23dd
commit 4ffa2e3993
39 changed files with 1055 additions and 832 deletions

View File

@@ -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()
}