Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ xcuserdata
# Python related
__pycache__
.localenvironment/

# Dart related
bdk-dart/.dart_tool/
44 changes: 44 additions & 0 deletions bdk-dart/example/generate_wallet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:bdk_dart/bdk.dart';

void main() {
// Generate a new mnemonic with 12 words
final mnemonic12 = Mnemonic(WordCount.words12);
print('12-word mnemonic: ${mnemonic12}');

// Generate a new mnemonic with 24 words
final mnemonic24 = Mnemonic(WordCount.words24);
print('24-word mnemonic: ${mnemonic24}');

// Create a BIP84 descriptor from the 12-word mnemonic
final descriptorSecretKey = DescriptorSecretKey(
Network.testnet,
mnemonic12,
null,
);

final descriptor = Descriptor.newBip84(
descriptorSecretKey,
KeychainKind.external_,
Network.testnet,
);

final changeDescriptor = Descriptor.newBip84(
descriptorSecretKey,
KeychainKind.internal,
Network.testnet,
);

// Create a wallet with the descriptor and in-memory persister
final wallet = Wallet(
descriptor,
changeDescriptor,
Network.testnet,
Persister.newInMemory(),
0,
);

// Generate a receive address
final addressInfo = wallet.nextUnusedAddress(KeychainKind.external_);
print('\nReceive address: ${addressInfo.address}');
print('Address index: ${addressInfo.index}');
}
Loading