-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to include P2PKH and P2WPKH classes in library exports #28
Conversation
@RohanKapurDEV why do you wanna to export this class. Could give me a context. And export p2wpkh also if need |
I wrote the following code while exploring how the library works: import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip39;
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
import 'package:bitcoin_flutter/src/models/networks.dart';
import 'package:flutter/material.dart';
class WalletService extends ChangeNotifier{
final entropy = '';
bip44test() {
final mnemonic = bip39.generateMnemonic();
final seed = bip39.mnemonicToSeed(mnemonic);
final root = bip32.BIP32.fromSeed(seed);
final node1 = root.derivePath("m/44'/0'/0'/0/0"); // (m/ purpose' / coin_type' / account_index' / chain(external_or_change) / address_index(external_or_change))
final node2 = root.derivePath("m/44'/0'/0'/0/1");
final node3 = root.derivePath("m/44'/0'/0'/0/2");
final address1 = P2PKH(data: new P2PKHData(pubkey: node1.publicKey)).data.address;
final address2 = P2PKH(data: new P2PKHData(pubkey: node2.publicKey)).data.address;
final address3 = P2PKH(data: new P2PKHData(pubkey: node3.publicKey)).data.address;
final changeNode1 = root.derivePath("m/44'/0'/0'/1/0");
final changeNode2 = root.derivePath("m/44'/0'/0'/1/1");
final changeNode3 = root.derivePath("m/44'/0'/0'/1/2");
final changeAddress1 = P2PKH(data: new P2PKHData(pubkey: changeNode1.publicKey)).data.address;
final changeAddress2 = P2PKH(data: new P2PKHData(pubkey: changeNode2.publicKey)).data.address;
final changeAddress3 = P2PKH(data: new P2PKHData(pubkey: changeNode3.publicKey)).data.address;
print('''
BIP39 Mnemonic: $mnemonic
BIP32 Master Node: $root
BIP44 Receiving Address 1: $address1
BIP44 Receiving Address 2: $address2
BIP44 Receiving Address 3: $address3
BIP44 Change Address 1: $changeAddress1
BIP44 Change Address 1: $changeAddress2
BIP44 Change Address 1: $changeAddress3
''');
}
} |
It is just random test code, not to be used in any real app. Only for exploring library |
i see, please help me export btw, Using fenced-code-blocks to embed code |
Ok, p2wpkh has also been added! |
just run test. 1 failed.
P/s: We should run test before pushing code |
P2WPKH class has been updated to include EMPTY_SCRIPT. I know I should be running all tests but i've been updating the lib from inside the GitHub editor due to my personal laptop being in a repair shop for a few days. I'll start runnning tests with each commit when I get it back for sure |
LGTM |
Quick edit to library main file to include access to P2PKH class