| 1 | import 'dart:typed_data'; |
| 2 | import 'package:bitcoin_base/bitcoin_base.dart'; |
| 3 | import 'package:blockchain_utils/blockchain_utils.dart'; |
| 4 | |
| 5 | ECPrivate generateECPrivate({ |
| 6 | required Bip32Slip10Secp256k1 hd, |
| 7 | required BasedUtxoNetwork network, |
| 8 | required int index, |
| 9 | }) => |
| 10 | ECPrivate(hd.childKey(Bip32KeyIndex(index)).privateKey); |
| 11 | |
| 12 | String generateP2WPKHAddress({ |
| 13 | required Bip32Slip10Secp256k1 hd, |
| 14 | required BasedUtxoNetwork network, |
| 15 | required int index, |
| 16 | }) => |
| 17 | ECPublic.fromBip32(hd.childKey(Bip32KeyIndex(index)).publicKey) |
| 18 | .toP2wpkhAddress() |
| 19 | .toAddress(network); |
| 20 | |
| 21 | String generateP2SHAddress({ |
| 22 | required Bip32Slip10Secp256k1 hd, |
| 23 | required BasedUtxoNetwork network, |
| 24 | required int index, |
| 25 | }) => |
| 26 | ECPublic.fromBip32(hd.childKey(Bip32KeyIndex(index)).publicKey) |
| 27 | .toP2wpkhInP2sh() |
| 28 | .toAddress(network); |
| 29 | |
| 30 | String generateP2WSHAddress({ |
| 31 | required Bip32Slip10Secp256k1 hd, |
| 32 | required BasedUtxoNetwork network, |
| 33 | required int index, |
| 34 | }) => |
| 35 | ECPublic.fromBip32(hd.childKey(Bip32KeyIndex(index)).publicKey) |
| 36 | .toP2wshAddress() |
| 37 | .toAddress(network); |
| 38 | |
| 39 | String generateP2PKHAddress({ |
| 40 | required Bip32Slip10Secp256k1 hd, |
| 41 | required BasedUtxoNetwork network, |
| 42 | required int index, |
| 43 | }) => |
| 44 | ECPublic.fromBip32(hd.childKey(Bip32KeyIndex(index)).publicKey) |
| 45 | .toP2pkhAddress() |
| 46 | .toAddress(network); |
| 47 | |
| 48 | String generateP2TRAddress({ |
| 49 | required Bip32Slip10Secp256k1 hd, |
| 50 | required BasedUtxoNetwork network, |
| 51 | required int index, |
| 52 | }) => |
| 53 | ECPublic.fromBip32(hd.childKey(Bip32KeyIndex(index)).publicKey) |
| 54 | .toTaprootAddress() |
| 55 | .toAddress(network); |