mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-19 01:04:43 +00:00
[skip ci] wip address changes
This commit is contained in:
parent
a673d3977f
commit
c94c10cc05
4 changed files with 40 additions and 2 deletions
|
@ -39,6 +39,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
Map<String, int>? initialChangeAddressIndex,
|
||||||
List<BitcoinSilentPaymentAddressRecord>? initialSilentAddresses,
|
List<BitcoinSilentPaymentAddressRecord>? initialSilentAddresses,
|
||||||
int initialSilentAddressIndex = 0,
|
int initialSilentAddressIndex = 0,
|
||||||
|
List<BitcoinAddressRecord>? initialMwebAddresses,
|
||||||
Bip32Slip10Secp256k1? masterHd,
|
Bip32Slip10Secp256k1? masterHd,
|
||||||
BitcoinAddressType? initialAddressPageType,
|
BitcoinAddressType? initialAddressPageType,
|
||||||
}) : _addresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? []).toSet()),
|
}) : _addresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? []).toSet()),
|
||||||
|
@ -59,6 +60,8 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
silentAddresses = ObservableList<BitcoinSilentPaymentAddressRecord>.of(
|
silentAddresses = ObservableList<BitcoinSilentPaymentAddressRecord>.of(
|
||||||
(initialSilentAddresses ?? []).toSet()),
|
(initialSilentAddresses ?? []).toSet()),
|
||||||
currentSilentAddressIndex = initialSilentAddressIndex,
|
currentSilentAddressIndex = initialSilentAddressIndex,
|
||||||
|
mwebAddresses =
|
||||||
|
ObservableList<BitcoinAddressRecord>.of((initialMwebAddresses ?? []).toSet()),
|
||||||
super(walletInfo) {
|
super(walletInfo) {
|
||||||
if (masterHd != null) {
|
if (masterHd != null) {
|
||||||
silentAddress = SilentPaymentOwner.fromPrivateKeys(
|
silentAddress = SilentPaymentOwner.fromPrivateKeys(
|
||||||
|
@ -101,6 +104,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
final ObservableList<BitcoinAddressRecord> receiveAddresses;
|
final ObservableList<BitcoinAddressRecord> receiveAddresses;
|
||||||
final ObservableList<BitcoinAddressRecord> changeAddresses;
|
final ObservableList<BitcoinAddressRecord> changeAddresses;
|
||||||
final ObservableList<BitcoinSilentPaymentAddressRecord> silentAddresses;
|
final ObservableList<BitcoinSilentPaymentAddressRecord> silentAddresses;
|
||||||
|
final ObservableList<BitcoinAddressRecord> mwebAddresses;
|
||||||
final BasedUtxoNetwork network;
|
final BasedUtxoNetwork network;
|
||||||
final Bip32Slip10Secp256k1 mainHd;
|
final Bip32Slip10Secp256k1 mainHd;
|
||||||
final Bip32Slip10Secp256k1 sideHd;
|
final Bip32Slip10Secp256k1 sideHd;
|
||||||
|
@ -607,6 +611,15 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
updateAddressesByMatch();
|
updateAddressesByMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
void addMwebAddresses(Iterable<BitcoinAddressRecord> addresses) {
|
||||||
|
final addressesSet = this.mwebAddresses.toSet();
|
||||||
|
addressesSet.addAll(addresses);
|
||||||
|
this.mwebAddresses.clear();
|
||||||
|
this.mwebAddresses.addAll(addressesSet);
|
||||||
|
updateAddressesByMatch();
|
||||||
|
}
|
||||||
|
|
||||||
void _validateAddresses() {
|
void _validateAddresses() {
|
||||||
_addresses.forEach((element) async {
|
_addresses.forEach((element) async {
|
||||||
if (!element.isHidden &&
|
if (!element.isHidden &&
|
||||||
|
|
|
@ -23,6 +23,7 @@ class ElectrumWalletSnapshot {
|
||||||
required this.addressPageType,
|
required this.addressPageType,
|
||||||
required this.silentAddresses,
|
required this.silentAddresses,
|
||||||
required this.silentAddressIndex,
|
required this.silentAddressIndex,
|
||||||
|
required this.mwebAddresses,
|
||||||
this.passphrase,
|
this.passphrase,
|
||||||
this.derivationType,
|
this.derivationType,
|
||||||
this.derivationPath,
|
this.derivationPath,
|
||||||
|
@ -44,6 +45,8 @@ class ElectrumWalletSnapshot {
|
||||||
|
|
||||||
List<BitcoinAddressRecord> addresses;
|
List<BitcoinAddressRecord> addresses;
|
||||||
List<BitcoinSilentPaymentAddressRecord> silentAddresses;
|
List<BitcoinSilentPaymentAddressRecord> silentAddresses;
|
||||||
|
List<BitcoinAddressRecord> mwebAddresses;
|
||||||
|
|
||||||
ElectrumBalance balance;
|
ElectrumBalance balance;
|
||||||
Map<String, int> regularAddressIndex;
|
Map<String, int> regularAddressIndex;
|
||||||
Map<String, int> changeAddressIndex;
|
Map<String, int> changeAddressIndex;
|
||||||
|
@ -71,6 +74,12 @@ class ElectrumWalletSnapshot {
|
||||||
.map((addr) => BitcoinSilentPaymentAddressRecord.fromJSON(addr, network: network))
|
.map((addr) => BitcoinSilentPaymentAddressRecord.fromJSON(addr, network: network))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
final mwebAddressTmp = data['mweb_addresses'] as List? ?? <Object>[];
|
||||||
|
final mwebAddresses = mwebAddressTmp
|
||||||
|
.whereType<String>()
|
||||||
|
.map((addr) => BitcoinAddressRecord.fromJSON(addr, network: network))
|
||||||
|
.toList();
|
||||||
|
|
||||||
final balance = ElectrumBalance.fromJSON(data['balance'] as String?) ??
|
final balance = ElectrumBalance.fromJSON(data['balance'] as String?) ??
|
||||||
ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
||||||
var regularAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
|
var regularAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
|
||||||
|
@ -113,6 +122,7 @@ class ElectrumWalletSnapshot {
|
||||||
derivationPath: derivationPath,
|
derivationPath: derivationPath,
|
||||||
silentAddresses: silentAddresses,
|
silentAddresses: silentAddresses,
|
||||||
silentAddressIndex: silentAddressIndex,
|
silentAddressIndex: silentAddressIndex,
|
||||||
|
mwebAddresses: mwebAddresses,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
String? passphrase,
|
String? passphrase,
|
||||||
String? addressPageType,
|
String? addressPageType,
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
|
List<BitcoinAddressRecord>? initialMwebAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
Map<String, int>? initialRegularAddressIndex,
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
Map<String, int>? initialChangeAddressIndex,
|
||||||
|
@ -69,6 +70,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
unspentCoinsInfo: unspentCoinsInfo,
|
unspentCoinsInfo: unspentCoinsInfo,
|
||||||
network: LitecoinNetwork.mainnet,
|
network: LitecoinNetwork.mainnet,
|
||||||
initialAddresses: initialAddresses,
|
initialAddresses: initialAddresses,
|
||||||
|
initialMwebAddresses: initialMwebAddresses,
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
seedBytes: seedBytes,
|
seedBytes: seedBytes,
|
||||||
encryptionFileUtils: encryptionFileUtils,
|
encryptionFileUtils: encryptionFileUtils,
|
||||||
|
@ -81,6 +83,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialAddresses: initialAddresses,
|
initialAddresses: initialAddresses,
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
|
initialMwebAddresses: initialMwebAddresses,
|
||||||
mainHd: hd,
|
mainHd: hd,
|
||||||
sideHd: accountHD.childKey(Bip32KeyIndex(1)),
|
sideHd: accountHD.childKey(Bip32KeyIndex(1)),
|
||||||
network: network,
|
network: network,
|
||||||
|
@ -111,6 +114,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
String? passphrase,
|
String? passphrase,
|
||||||
String? addressPageType,
|
String? addressPageType,
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
|
List<BitcoinAddressRecord>? initialMwebAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
Map<String, int>? initialRegularAddressIndex,
|
||||||
Map<String, int>? initialChangeAddressIndex}) async {
|
Map<String, int>? initialChangeAddressIndex}) async {
|
||||||
|
@ -134,6 +138,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
unspentCoinsInfo: unspentCoinsInfo,
|
unspentCoinsInfo: unspentCoinsInfo,
|
||||||
initialAddresses: initialAddresses,
|
initialAddresses: initialAddresses,
|
||||||
|
initialMwebAddresses: initialMwebAddresses,
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
encryptionFileUtils: encryptionFileUtils,
|
encryptionFileUtils: encryptionFileUtils,
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
|
@ -213,6 +218,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
unspentCoinsInfo: unspentCoinsInfo,
|
unspentCoinsInfo: unspentCoinsInfo,
|
||||||
initialAddresses: snp?.addresses,
|
initialAddresses: snp?.addresses,
|
||||||
|
initialMwebAddresses: snp?.mwebAddresses,
|
||||||
initialBalance: snp?.balance,
|
initialBalance: snp?.balance,
|
||||||
seedBytes: seedBytes!,
|
seedBytes: seedBytes!,
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
|
|
|
@ -25,15 +25,23 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
||||||
required this.mwebHd,
|
required this.mwebHd,
|
||||||
required this.mwebEnabled,
|
required this.mwebEnabled,
|
||||||
super.initialAddresses,
|
super.initialAddresses,
|
||||||
|
super.initialMwebAddresses,
|
||||||
super.initialRegularAddressIndex,
|
super.initialRegularAddressIndex,
|
||||||
super.initialChangeAddressIndex,
|
super.initialChangeAddressIndex,
|
||||||
}) : super(walletInfo) {}
|
}) : super(walletInfo) {
|
||||||
|
for (int i = 0; i < mwebAddresses.length; i++) {
|
||||||
|
mwebAddrs.add(mwebAddresses[i].address);
|
||||||
|
}
|
||||||
|
print("initialized with ${mwebAddrs.length} mweb addresses");
|
||||||
|
if (mwebAddrs.length < 1000) {
|
||||||
|
initMwebAddresses();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Bip32Slip10Secp256k1 mwebHd;
|
final Bip32Slip10Secp256k1 mwebHd;
|
||||||
bool mwebEnabled;
|
bool mwebEnabled;
|
||||||
int mwebTopUpIndex = 1000;
|
int mwebTopUpIndex = 1000;
|
||||||
List<String> mwebAddrs = [];
|
List<String> mwebAddrs = [];
|
||||||
static Timer? mwebTopUpTimer;
|
|
||||||
|
|
||||||
List<int> get scanSecret => mwebHd.childKey(Bip32KeyIndex(0x80000000)).privateKey.privKey.raw;
|
List<int> get scanSecret => mwebHd.childKey(Bip32KeyIndex(0x80000000)).privateKey.privKey.raw;
|
||||||
List<int> get spendPubkey =>
|
List<int> get spendPubkey =>
|
||||||
|
@ -89,6 +97,7 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
||||||
.toList();
|
.toList();
|
||||||
// add them to the list of all addresses:
|
// add them to the list of all addresses:
|
||||||
addAddresses(mwebAddresses);
|
addAddresses(mwebAddresses);
|
||||||
|
addMwebAddresses(mwebAddresses);
|
||||||
print("MWEB addresses initialized ${mwebAddrs.length}");
|
print("MWEB addresses initialized ${mwebAddrs.length}");
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue