2021-12-24 12:52:08 +00:00
|
|
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
2022-01-18 16:27:33 +00:00
|
|
|
import 'package:cw_bitcoin/electrum.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
import 'package:cw_bitcoin/utils.dart';
|
|
|
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
|
|
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
|
|
|
import 'package:cw_core/wallet_info.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
|
|
|
|
part 'bitcoin_wallet_addresses.g.dart';
|
|
|
|
|
2023-10-06 15:20:45 +00:00
|
|
|
class BitcoinWalletAddresses = BitcoinWalletAddressesBase with _$BitcoinWalletAddresses;
|
2021-12-24 12:52:08 +00:00
|
|
|
|
2023-10-06 15:20:45 +00:00
|
|
|
abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
|
|
|
BitcoinWalletAddressesBase(WalletInfo walletInfo,
|
2022-10-12 17:09:57 +00:00
|
|
|
{required bitcoin.HDWallet mainHd,
|
2023-10-06 15:20:45 +00:00
|
|
|
required bitcoin.HDWallet sideHd,
|
|
|
|
required bitcoin.NetworkType networkType,
|
|
|
|
required ElectrumClient electrumClient,
|
|
|
|
List<BitcoinAddressRecord>? initialAddresses,
|
|
|
|
int initialRegularAddressIndex = 0,
|
|
|
|
int initialChangeAddressIndex = 0,
|
|
|
|
bitcoin.SilentPaymentAddress? silentAddress})
|
|
|
|
: super(walletInfo,
|
|
|
|
initialAddresses: initialAddresses,
|
|
|
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
|
|
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
|
|
|
mainHd: mainHd,
|
|
|
|
sideHd: sideHd,
|
|
|
|
electrumClient: electrumClient,
|
|
|
|
networkType: networkType,
|
|
|
|
silentAddress: silentAddress);
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
@override
|
2022-10-12 17:09:57 +00:00
|
|
|
String getAddress({required int index, required bitcoin.HDWallet hd}) =>
|
2021-12-24 12:52:08 +00:00
|
|
|
generateP2WPKHAddress(hd: hd, index: index, networkType: networkType);
|
2023-10-06 15:20:45 +00:00
|
|
|
}
|
|
|
|
|