Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.history
.dart_tool/

.packages
Expand Down
30 changes: 20 additions & 10 deletions lib/core/hd_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,33 @@ class HDWallet {
}

HDWallet({int strength = 128, String passphrase = ""}) {
_nativehandle = TWHDWalletImpl.create(strength: strength, passphrase: passphrase);
if (_nativehandle.hashCode == 0) throw Exception(["HDWallet nativehandle is null"]);
_nativehandle =
TWHDWalletImpl.create(strength: strength, passphrase: passphrase);
if (_nativehandle.hashCode == 0)
throw Exception(["HDWallet nativehandle is null"]);
}

HDWallet.createWithMnemonic(String mnemonic, {String passphrase = ""}) {
_nativehandle = TWHDWalletImpl.createWithMnemonic(mnemonic, passphrase: passphrase);
if (_nativehandle.hashCode == 0) throw Exception(["HDWallet nativehandle is null"]);
_nativehandle =
TWHDWalletImpl.createWithMnemonic(mnemonic, passphrase: passphrase);
if (_nativehandle.hashCode == 0)
throw Exception(["HDWallet nativehandle is null"]);
}

HDWallet.createWithData(Uint8List bytes, {String passphrase = ""}) {
_nativehandle = TWHDWalletImpl.createWithEntropy(bytes, passphrase: passphrase);
if (_nativehandle.hashCode == 0) throw Exception(["HDWallet nativehandle is null"]);
_nativehandle =
TWHDWalletImpl.createWithEntropy(bytes, passphrase: passphrase);
if (_nativehandle.hashCode == 0)
throw Exception(["HDWallet nativehandle is null"]);
}

String getAddressForCoin(int coinType) {
return TWHDWalletImpl.getAddressForCoin(_nativehandle, coinType);
}

PrivateKey getDerivedKey(int coinType, int account, int change, int address) {
final pointer = TWHDWalletImpl.getDerivedKey(_nativehandle, coinType, account, change, address);
final pointer = TWHDWalletImpl.getDerivedKey(
_nativehandle, coinType, account, change, address);
return PrivateKey._(pointer);
}

Expand All @@ -37,11 +44,13 @@ class HDWallet {
}

PrivateKey getKey(int coinType, String derivationPath) {
final pointer = TWHDWalletImpl.getKey(_nativehandle, coinType, derivationPath);
final pointer =
TWHDWalletImpl.getKey(_nativehandle, coinType, derivationPath);
return PrivateKey._(pointer);
}

PrivateKey getMaterKey(int curve) {
/// getMasterKey
PrivateKey getMasterKey(int curve) {
final pointer = TWHDWalletImpl.getMasterKey(_nativehandle, curve);
return PrivateKey._(pointer);
}
Expand All @@ -59,6 +68,7 @@ class HDWallet {
}

String getExtendedPublicKey(int purpose, int coinType, int twHdVersion) {
return TWHDWalletImpl.getExtendedPublicKey(_nativehandle, purpose, coinType, twHdVersion);
return TWHDWalletImpl.getExtendedPublicKey(
_nativehandle, purpose, coinType, twHdVersion);
}
}