Closed RohanKapurDEV closed 4 years ago
@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: I had to add that line to use P2PKH class.
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 p2wpkh.dart
also
btw, Using fenced-code-blocks to embed code
Ok, p2wpkh has also been added!
just run test. 1 failed.
Help me move final EMPTY_SCRIPT = Uint8List.fromList([]);
at lib/src/payments/p2wpkh.dart go inside P2WPKH
class. Because EMPTY_SCRIPT
already exported at transaction.dart
$ pub run test
00:10 +97 -1: loading test/bitcoin_test.dart [E]
Failed to load "test/bitcoin_test.dart":
Unable to spawn isolate: lib/bitcoin_flutter.dart:12:1: Error: 'EMPTY_SCRIPT' is exported from both 'package:bitcoin_flutter/src/transaction.dart' and 'package:bitcoin_flutter/src/payments/p2wpkh.dart'.
export 'src/payments/p2wpkh.dart';
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