2024-04-20 23:20:52 +00:00
|
|
|
import 'dart:async';
|
2024-04-22 16:18:18 +00:00
|
|
|
import 'package:convert/convert.dart';
|
2024-04-22 23:26:34 +00:00
|
|
|
import 'package:crypto/crypto.dart';
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
import 'package:bitcoin_base/bitcoin_base.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
|
|
|
import 'package:cw_bitcoin/bitcoin_transaction_priority.dart';
|
2024-04-22 16:18:18 +00:00
|
|
|
import 'package:cw_bitcoin/electrum_transaction_info.dart';
|
2022-10-12 17:09:57 +00:00
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2024-04-21 11:19:44 +00:00
|
|
|
import 'package:cw_core/sync_status.dart';
|
2024-04-22 16:18:18 +00:00
|
|
|
import 'package:cw_core/transaction_direction.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
|
|
import 'package:cw_bitcoin/litecoin_wallet_addresses.dart';
|
|
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
import 'package:cw_core/wallet_info.dart';
|
2024-04-22 16:18:18 +00:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
import 'package:cw_bitcoin/electrum_wallet_snapshot.dart';
|
|
|
|
import 'package:cw_bitcoin/electrum_wallet.dart';
|
|
|
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
|
|
|
import 'package:cw_bitcoin/electrum_balance.dart';
|
|
|
|
import 'package:cw_bitcoin/litecoin_network.dart';
|
2024-04-20 23:20:52 +00:00
|
|
|
import 'package:cw_mweb/cw_mweb.dart';
|
|
|
|
import 'package:cw_mweb/mwebd.pb.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
|
|
|
|
|
|
|
part 'litecoin_wallet.g.dart';
|
|
|
|
|
|
|
|
class LitecoinWallet = LitecoinWalletBase with _$LitecoinWallet;
|
|
|
|
|
|
|
|
abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
LitecoinWalletBase({
|
|
|
|
required String mnemonic,
|
|
|
|
required String password,
|
|
|
|
required WalletInfo walletInfo,
|
|
|
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
|
|
|
required Uint8List seedBytes,
|
|
|
|
String? addressPageType,
|
|
|
|
List<BitcoinAddressRecord>? initialAddresses,
|
|
|
|
ElectrumBalance? initialBalance,
|
|
|
|
Map<String, int>? initialRegularAddressIndex,
|
|
|
|
Map<String, int>? initialChangeAddressIndex,
|
2024-04-22 16:18:18 +00:00
|
|
|
}) : mwebHd = bitcoin.HDWallet.fromSeed(seedBytes,
|
|
|
|
network: litecoinNetwork).derivePath("m/1000'"),
|
|
|
|
super(
|
2021-12-24 12:52:08 +00:00
|
|
|
mnemonic: mnemonic,
|
|
|
|
password: password,
|
|
|
|
walletInfo: walletInfo,
|
|
|
|
unspentCoinsInfo: unspentCoinsInfo,
|
|
|
|
networkType: litecoinNetwork,
|
|
|
|
initialAddresses: initialAddresses,
|
2022-10-12 17:09:57 +00:00
|
|
|
initialBalance: initialBalance,
|
|
|
|
seedBytes: seedBytes,
|
|
|
|
currency: CryptoCurrency.ltc) {
|
2021-12-24 12:52:08 +00:00
|
|
|
walletAddresses = LitecoinWalletAddresses(
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
walletInfo,
|
|
|
|
electrumClient: electrumClient,
|
|
|
|
initialAddresses: initialAddresses,
|
|
|
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
|
|
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
|
|
|
mainHd: hd,
|
|
|
|
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType).derivePath("m/0'/1"),
|
2024-04-22 16:18:18 +00:00
|
|
|
mwebHd: mwebHd,
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
network: network,
|
|
|
|
);
|
2024-01-23 05:15:24 +00:00
|
|
|
autorun((_) {
|
|
|
|
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
|
|
|
});
|
2021-12-24 12:52:08 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 16:18:18 +00:00
|
|
|
final bitcoin.HDWallet mwebHd;
|
|
|
|
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
static Future<LitecoinWallet> create(
|
|
|
|
{required String mnemonic,
|
|
|
|
required String password,
|
|
|
|
required WalletInfo walletInfo,
|
|
|
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
|
|
|
String? addressPageType,
|
|
|
|
List<BitcoinAddressRecord>? initialAddresses,
|
|
|
|
ElectrumBalance? initialBalance,
|
|
|
|
Map<String, int>? initialRegularAddressIndex,
|
|
|
|
Map<String, int>? initialChangeAddressIndex}) async {
|
2022-10-12 17:09:57 +00:00
|
|
|
return LitecoinWallet(
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
mnemonic: mnemonic,
|
|
|
|
password: password,
|
|
|
|
walletInfo: walletInfo,
|
|
|
|
unspentCoinsInfo: unspentCoinsInfo,
|
|
|
|
initialAddresses: initialAddresses,
|
|
|
|
initialBalance: initialBalance,
|
|
|
|
seedBytes: await mnemonicToSeedBytes(mnemonic),
|
|
|
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
|
|
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
|
|
|
addressPageType: addressPageType,
|
|
|
|
);
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 12:52:08 +00:00
|
|
|
static Future<LitecoinWallet> open({
|
2022-10-12 17:09:57 +00:00
|
|
|
required String name,
|
|
|
|
required WalletInfo walletInfo,
|
|
|
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
|
|
|
required String password,
|
2021-12-24 12:52:08 +00:00
|
|
|
}) async {
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
final snp =
|
|
|
|
await ElectrumWalletSnapshot.load(name, walletInfo.type, password, LitecoinNetwork.mainnet);
|
2021-12-24 12:52:08 +00:00
|
|
|
return LitecoinWallet(
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 16:13:30 +00:00
|
|
|
mnemonic: snp.mnemonic,
|
|
|
|
password: password,
|
|
|
|
walletInfo: walletInfo,
|
|
|
|
unspentCoinsInfo: unspentCoinsInfo,
|
|
|
|
initialAddresses: snp.addresses,
|
|
|
|
initialBalance: snp.balance,
|
|
|
|
seedBytes: await mnemonicToSeedBytes(snp.mnemonic),
|
|
|
|
initialRegularAddressIndex: snp.regularAddressIndex,
|
|
|
|
initialChangeAddressIndex: snp.changeAddressIndex,
|
|
|
|
addressPageType: snp.addressPageType,
|
|
|
|
);
|
2021-12-24 12:52:08 +00:00
|
|
|
}
|
|
|
|
|
2024-04-20 23:20:52 +00:00
|
|
|
@action
|
|
|
|
@override
|
|
|
|
Future<void> startSync() async {
|
2024-04-21 11:19:44 +00:00
|
|
|
await super.startSync();
|
2024-04-21 18:58:45 +00:00
|
|
|
final stub = await CwMweb.stub();
|
2024-04-20 23:20:52 +00:00
|
|
|
Timer.periodic(
|
2024-04-21 11:19:44 +00:00
|
|
|
const Duration(milliseconds: 1500), (timer) async {
|
|
|
|
final height = await electrumClient.getCurrentBlockChainTip() ?? 0;
|
2024-04-20 23:20:52 +00:00
|
|
|
final resp = await stub.status(StatusRequest());
|
2024-04-21 11:19:44 +00:00
|
|
|
if (resp.blockHeaderHeight < height) {
|
|
|
|
int h = resp.blockHeaderHeight;
|
|
|
|
syncStatus = SyncingSyncStatus(height - h, h / height);
|
|
|
|
} else if (resp.mwebHeaderHeight < height) {
|
|
|
|
int h = resp.mwebHeaderHeight;
|
|
|
|
syncStatus = SyncingSyncStatus(height - h, h / height);
|
|
|
|
} else if (resp.mwebUtxosHeight < height) {
|
|
|
|
syncStatus = SyncingSyncStatus(1, 0.999);
|
|
|
|
} else {
|
|
|
|
syncStatus = SyncedSyncStatus();
|
|
|
|
}
|
2024-04-20 23:20:52 +00:00
|
|
|
});
|
2024-04-22 23:26:34 +00:00
|
|
|
processMwebUtxos();
|
|
|
|
}
|
|
|
|
|
|
|
|
final Map<String, Utxo> mwebUtxos = {};
|
|
|
|
|
|
|
|
Future<void> processMwebUtxos() async {
|
|
|
|
final stub = await CwMweb.stub();
|
2024-04-22 16:18:18 +00:00
|
|
|
final scanSecret = mwebHd.derive(0x80000000).privKey!;
|
|
|
|
final req = UtxosRequest(scanSecret: hex.decode(scanSecret));
|
|
|
|
await for (var utxo in stub.utxos(req)) {
|
2024-04-22 23:26:34 +00:00
|
|
|
final mwebAddrs = (walletAddresses as LitecoinWalletAddresses).mwebAddrs;
|
|
|
|
if (!mwebAddrs.contains(utxo.address)) continue;
|
|
|
|
mwebUtxos[utxo.outputId] = utxo;
|
|
|
|
|
2024-04-22 16:18:18 +00:00
|
|
|
final status = await stub.status(StatusRequest());
|
|
|
|
var date = DateTime.now();
|
|
|
|
var confirmations = 0;
|
|
|
|
if (utxo.height > 0) {
|
|
|
|
date = await electrumClient.getBlockTime(height: utxo.height);
|
|
|
|
confirmations = status.blockHeaderHeight - utxo.height + 1;
|
|
|
|
}
|
|
|
|
final tx = ElectrumTransactionInfo(WalletType.litecoin,
|
|
|
|
id: utxo.outputId, height: utxo.height,
|
2024-04-22 17:07:59 +00:00
|
|
|
amount: utxo.value.toInt(), fee: 0,
|
2024-04-22 16:18:18 +00:00
|
|
|
direction: TransactionDirection.incoming,
|
|
|
|
isPending: utxo.height == 0,
|
2024-04-22 17:07:59 +00:00
|
|
|
date: date, confirmations: confirmations,
|
|
|
|
inputAddresses: [],
|
|
|
|
outputAddresses: [utxo.address]);
|
2024-04-22 16:18:18 +00:00
|
|
|
transactionHistory.addOne(tx);
|
|
|
|
await transactionHistory.save();
|
|
|
|
}
|
2024-04-20 23:20:52 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 23:26:34 +00:00
|
|
|
Future<void> checkMwebUtxosSpent() async {
|
|
|
|
final List<String> outputIds = [];
|
|
|
|
mwebUtxos.forEach((outputId, utxo) {
|
|
|
|
if (utxo.height > 0)
|
|
|
|
outputIds.add(outputId);
|
|
|
|
});
|
|
|
|
final stub = await CwMweb.stub();
|
|
|
|
final resp = await stub.spent(SpentRequest(outputId: outputIds));
|
|
|
|
final spent = resp.outputId;
|
|
|
|
if (spent.isEmpty) return;
|
|
|
|
final status = await stub.status(StatusRequest());
|
|
|
|
final height = await electrumClient.getCurrentBlockChainTip();
|
|
|
|
if (height == null || status.mwebUtxosHeight != height) return;
|
|
|
|
final date = await electrumClient.getBlockTime(height: height);
|
|
|
|
int amount = 0;
|
|
|
|
Set<String> inputAddresses = {};
|
|
|
|
var output = AccumulatorSink<Digest>();
|
|
|
|
var input = sha256.startChunkedConversion(output);
|
|
|
|
for (final outputId in spent) {
|
|
|
|
input.add(hex.decode(outputId));
|
|
|
|
amount += mwebUtxos[outputId]!.value.toInt();
|
|
|
|
inputAddresses.add(mwebUtxos[outputId]!.address);
|
|
|
|
mwebUtxos.remove(outputId);
|
|
|
|
}
|
|
|
|
input.close();
|
|
|
|
var digest = output.events.single;
|
|
|
|
final tx = ElectrumTransactionInfo(WalletType.litecoin,
|
|
|
|
id: digest.toString(), height: height,
|
|
|
|
amount: amount, fee: 0,
|
|
|
|
direction: TransactionDirection.outgoing,
|
|
|
|
isPending: false,
|
|
|
|
date: date, confirmations: 1,
|
|
|
|
inputAddresses: inputAddresses.toList(),
|
|
|
|
outputAddresses: []);
|
|
|
|
transactionHistory.addOne(tx);
|
|
|
|
await transactionHistory.save();
|
|
|
|
}
|
|
|
|
|
2021-12-24 12:52:08 +00:00
|
|
|
@override
|
|
|
|
int feeRate(TransactionPriority priority) {
|
|
|
|
if (priority is LitecoinTransactionPriority) {
|
|
|
|
switch (priority) {
|
|
|
|
case LitecoinTransactionPriority.slow:
|
|
|
|
return 1;
|
|
|
|
case LitecoinTransactionPriority.medium:
|
|
|
|
return 2;
|
|
|
|
case LitecoinTransactionPriority.fast:
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|