mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-29 15:09:23 +00:00
42 lines
1.5 KiB
Dart
42 lines
1.5 KiB
Dart
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
|
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
|
import 'package:cw_bitcoin/utils.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
part 'bitcoin_wallet_addresses.g.dart';
|
|
|
|
class BitcoinWalletAddresses = BitcoinWalletAddressesBase with _$BitcoinWalletAddresses;
|
|
|
|
abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
|
BitcoinWalletAddressesBase(
|
|
WalletInfo walletInfo, {
|
|
required super.mainHd,
|
|
required super.sideHd,
|
|
required super.network,
|
|
super.initialAddresses,
|
|
super.initialRegularAddressIndex,
|
|
super.initialChangeAddressIndex,
|
|
super.initialSilentAddresses,
|
|
super.initialSilentAddressIndex = 0,
|
|
super.masterHd,
|
|
}) : super(walletInfo);
|
|
|
|
@override
|
|
String getAddress({required int index, required HDWallet hd, BitcoinAddressType? addressType}) {
|
|
if (addressType == P2pkhAddressType.p2pkh)
|
|
return generateP2PKHAddress(hd: hd, index: index, network: network);
|
|
|
|
if (addressType == SegwitAddresType.p2tr)
|
|
return generateP2TRAddress(hd: hd, index: index, network: network);
|
|
|
|
if (addressType == SegwitAddresType.p2wsh)
|
|
return generateP2WSHAddress(hd: hd, index: index, network: network);
|
|
|
|
if (addressType == P2shAddressType.p2wpkhInP2sh)
|
|
return generateP2SHAddress(hd: hd, index: index, network: network);
|
|
|
|
return generateP2WPKHAddress(hd: hd, index: index, network: network);
|
|
}
|
|
}
|