mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
bbba41396d
* refactor: remove bitcoin_flutter, update deps, electrs node improvements * feat: connecting/disconnecting improvements, fix rescan by date, scanning message * chore: print * Update pubspec.yaml * Update pubspec.yaml * handle null sockets, retry connection on connect failure * fix imports * fix transaction history * fix RBF * minor fixes/readability enhancements [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> Co-authored-by: Matthew Fosse <matt@fosse.co>
43 lines
1.5 KiB
Dart
43 lines
1.5 KiB
Dart
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
import 'package:blockchain_utils/bip/bip/bip32/bip32.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 Bip32Slip10Secp256k1 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);
|
|
}
|
|
}
|