forked from rikitau/rust-bip85
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d820f10
commit e9194c7
Showing
17 changed files
with
34 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
use std::str::FromStr; | ||
|
||
use bip85_fork::bitcoin::bip32::{DerivationPath, Xpriv}; | ||
use bip85_fork::bitcoin::secp256k1::Secp256k1; | ||
use bip85_extended::bitcoin::bip32::{DerivationPath, Xpriv}; | ||
use bip85_extended::bitcoin::secp256k1::Secp256k1; | ||
|
||
#[flutter_rust_bridge::frb(sync)] | ||
pub fn derive(xprv: String, path: String) -> Vec<u8> { | ||
let root = Xpriv::from_str(&xprv).unwrap(); | ||
let derivation_path = DerivationPath::from_str(&path).unwrap(); | ||
let derived = bip85_fork::derive(&Secp256k1::new(), &root, &derivation_path).unwrap(); | ||
let derived = bip85_extended::derive(&Secp256k1::new(), &root, &derivation_path).unwrap(); | ||
return derived; | ||
} | ||
|
||
#[flutter_rust_bridge::frb(sync)] | ||
pub fn to_wif(xprv: String, index: u32) -> String { | ||
let root = Xpriv::from_str(&xprv).unwrap(); | ||
let derived = bip85_fork::to_wif(&Secp256k1::new(), &root, index).unwrap(); | ||
let derived = bip85_extended::to_wif(&Secp256k1::new(), &root, index).unwrap(); | ||
return derived.to_string(); | ||
} | ||
|
||
#[flutter_rust_bridge::frb(sync)] | ||
pub fn to_xprv(xprv: String, index: u32) -> String { | ||
let root = Xpriv::from_str(&xprv).unwrap(); | ||
let derived = bip85_fork::to_xprv(&Secp256k1::new(), &root, index).unwrap(); | ||
let derived = bip85_extended::to_xprv(&Secp256k1::new(), &root, index).unwrap(); | ||
return derived.to_string(); | ||
} | ||
|
||
#[flutter_rust_bridge::frb(sync)] | ||
pub fn to_hex(xprv: String, length: u32, index: u32) -> String { | ||
let root = Xpriv::from_str(&xprv).unwrap(); | ||
let derived = bip85_fork::to_hex(&Secp256k1::new(), &root, length, index).unwrap(); | ||
let derived = bip85_extended::to_hex(&Secp256k1::new(), &root, length, index).unwrap(); | ||
return derived; | ||
} | ||
|
||
#[flutter_rust_bridge::frb(sync)] | ||
pub fn to_mnemonic(xprv: String, word_count: u32, index: u32) -> String { | ||
let root = Xpriv::from_str(&xprv).unwrap(); | ||
let derived = bip85_fork::to_mnemonic(&Secp256k1::new(), &root, word_count, index).unwrap(); | ||
let derived = bip85_extended::to_mnemonic(&Secp256k1::new(), &root, word_count, index).unwrap(); | ||
return derived.to_string(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use bip85_fork::*; | ||
use bip85_extended::*; | ||
use bitcoin::{bip32::Xpriv, key::Secp256k1}; | ||
use std::str::FromStr; | ||
|
||
|