Removed ExtendedKeyInfo & related methods
This commit is contained in:
parent
d38737669d
commit
973013cbdf
14
src/bdk.udl
14
src/bdk.udl
@ -1,10 +1,4 @@
|
|||||||
namespace bdk {
|
namespace bdk {};
|
||||||
[Throws=BdkError]
|
|
||||||
ExtendedKeyInfo generate_extended_key(Network network, WordCount word_count, string? password);
|
|
||||||
|
|
||||||
[Throws=BdkError]
|
|
||||||
ExtendedKeyInfo restore_extended_key(Network network, string mnemonic, string? password);
|
|
||||||
};
|
|
||||||
|
|
||||||
[Error]
|
[Error]
|
||||||
enum BdkError {
|
enum BdkError {
|
||||||
@ -101,12 +95,6 @@ interface Transaction {
|
|||||||
Confirmed(TransactionDetails details, BlockTime confirmation);
|
Confirmed(TransactionDetails details, BlockTime confirmation);
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary ExtendedKeyInfo {
|
|
||||||
string mnemonic;
|
|
||||||
string xprv;
|
|
||||||
string fingerprint;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum WordCount {
|
enum WordCount {
|
||||||
"Words12",
|
"Words12",
|
||||||
"Words15",
|
"Words15",
|
||||||
|
40
src/lib.rs
40
src/lib.rs
@ -351,46 +351,6 @@ impl Wallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ExtendedKeyInfo {
|
|
||||||
mnemonic: String,
|
|
||||||
xprv: String,
|
|
||||||
fingerprint: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_extended_key(
|
|
||||||
network: Network,
|
|
||||||
word_count: WordCount,
|
|
||||||
password: Option<String>,
|
|
||||||
) -> Result<ExtendedKeyInfo, Error> {
|
|
||||||
let mnemonic: GeneratedKey<_, BareCtx> =
|
|
||||||
Mnemonic::generate((word_count, Language::English)).unwrap();
|
|
||||||
let mnemonic = mnemonic.into_key();
|
|
||||||
let xkey: ExtendedKey = (mnemonic.clone(), password).into_extended_key()?;
|
|
||||||
let xprv = xkey.into_xprv(network).unwrap();
|
|
||||||
let fingerprint = xprv.fingerprint(&Secp256k1::new());
|
|
||||||
Ok(ExtendedKeyInfo {
|
|
||||||
mnemonic: mnemonic.to_string(),
|
|
||||||
xprv: xprv.to_string(),
|
|
||||||
fingerprint: fingerprint.to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn restore_extended_key(
|
|
||||||
network: Network,
|
|
||||||
mnemonic: String,
|
|
||||||
password: Option<String>,
|
|
||||||
) -> Result<ExtendedKeyInfo, Error> {
|
|
||||||
let mnemonic = Mnemonic::parse_in(Language::English, mnemonic).unwrap();
|
|
||||||
let xkey: ExtendedKey = (mnemonic.clone(), password).into_extended_key()?;
|
|
||||||
let xprv = xkey.into_xprv(network).unwrap();
|
|
||||||
let fingerprint = xprv.fingerprint(&Secp256k1::new());
|
|
||||||
Ok(ExtendedKeyInfo {
|
|
||||||
mnemonic: mnemonic.to_string(),
|
|
||||||
xprv: xprv.to_string(),
|
|
||||||
fingerprint: fingerprint.to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_script_pubkey(address: &str) -> Result<Script, BdkError> {
|
fn to_script_pubkey(address: &str) -> Result<Script, BdkError> {
|
||||||
Address::from_str(address)
|
Address::from_str(address)
|
||||||
.map(|x| x.script_pubkey())
|
.map(|x| x.script_pubkey())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user