2021-12-24 12:52:08 +00:00
import ' dart:async ' ;
import ' dart:convert ' ;
2023-07-12 23:20:11 +00:00
import ' dart:io ' ;
2024-02-26 18:32:54 +00:00
import ' dart:isolate ' ;
2022-01-12 13:20:43 +00:00
import ' dart:math ' ;
2023-11-15 23:12:23 +00:00
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:bitcoin_flutter/bitcoin_flutter.dart ' as bitcoin ;
2024-02-26 18:33:31 +00:00
import ' package:blockchain_utils/blockchain_utils.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:collection/collection.dart ' ;
2024-04-08 14:54:58 +00:00
import ' package:cw_bitcoin/address_from_output.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_bitcoin/bitcoin_address_record.dart ' ;
2024-03-29 18:51:34 +00:00
import ' package:cw_bitcoin/bitcoin_amount_format.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_bitcoin/bitcoin_transaction_credentials.dart ' ;
import ' package:cw_bitcoin/bitcoin_transaction_priority.dart ' ;
import ' package:cw_bitcoin/bitcoin_unspent.dart ' ;
import ' package:cw_bitcoin/bitcoin_wallet_keys.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:cw_bitcoin/electrum.dart ' ;
import ' package:cw_bitcoin/electrum_balance.dart ' ;
import ' package:cw_bitcoin/electrum_transaction_history.dart ' ;
import ' package:cw_bitcoin/electrum_transaction_info.dart ' ;
import ' package:cw_bitcoin/electrum_wallet_addresses.dart ' ;
2024-03-29 18:51:34 +00:00
import ' package:cw_bitcoin/exceptions.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:cw_bitcoin/litecoin_network.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_bitcoin/pending_bitcoin_transaction.dart ' ;
import ' package:cw_bitcoin/script_hash.dart ' ;
import ' package:cw_bitcoin/utils.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:cw_core/crypto_currency.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_core/node.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:cw_core/pathForWallet.dart ' ;
import ' package:cw_core/pending_transaction.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_core/sync_status.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:cw_core/transaction_direction.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_core/transaction_priority.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:cw_core/unspent_coins_info.dart ' ;
2023-12-02 01:02:55 +00:00
import ' package:cw_core/utils/file.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:cw_core/wallet_base.dart ' ;
2021-12-24 12:52:08 +00:00
import ' package:cw_core/wallet_info.dart ' ;
2024-02-27 14:40:56 +00:00
import ' package:cw_core/wallet_type.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:flutter/foundation.dart ' ;
import ' package:hive/hive.dart ' ;
import ' package:mobx/mobx.dart ' ;
import ' package:rxdart/subjects.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:http/http.dart ' as http ;
2021-12-24 12:52:08 +00:00
part ' electrum_wallet.g.dart ' ;
class ElectrumWallet = ElectrumWalletBase with _ $ElectrumWallet ;
2023-10-12 22:50:16 +00:00
abstract class ElectrumWalletBase
extends WalletBase < ElectrumBalance , ElectrumTransactionHistory , ElectrumTransactionInfo >
with Store {
2021-12-24 12:52:08 +00:00
ElectrumWalletBase (
2022-10-12 17:09:57 +00:00
{ required String password ,
2023-11-15 23:12:23 +00:00
required WalletInfo walletInfo ,
required Box < UnspentCoinsInfo > unspentCoinsInfo ,
required this . networkType ,
required this . mnemonic ,
required Uint8List seedBytes ,
List < BitcoinAddressRecord > ? initialAddresses ,
ElectrumClient ? electrumClient ,
ElectrumBalance ? initialBalance ,
CryptoCurrency ? currency } )
2023-10-12 22:50:16 +00:00
: hd = currency = = CryptoCurrency . bch
2023-11-15 23:12:23 +00:00
? bitcoinCashHDWallet ( seedBytes )
: bitcoin . HDWallet . fromSeed ( seedBytes , network: networkType ) . derivePath ( " m/0'/0 " ) ,
2021-12-24 12:52:08 +00:00
syncStatus = NotConnectedSyncStatus ( ) ,
_password = password ,
_feeRates = < int > [ ] ,
_isTransactionUpdating = false ,
2024-01-23 05:15:24 +00:00
isEnabledAutoGenerateSubaddress = true ,
2022-10-12 17:09:57 +00:00
unspentCoins = [ ] ,
_scripthashesUpdateSubject = { } ,
2023-10-12 22:50:16 +00:00
balance = ObservableMap < CryptoCurrency , ElectrumBalance > . of ( currency ! = null
? {
2024-03-11 12:46:20 +00:00
currency: initialBalance ? ?
ElectrumBalance (
confirmed: 0 ,
unconfirmed: 0 ,
frozen: 0 ,
)
2023-11-15 23:12:23 +00:00
}
2023-10-12 22:50:16 +00:00
: { } ) ,
2022-10-12 17:09:57 +00:00
this . unspentCoinsInfo = unspentCoinsInfo ,
2024-03-21 02:51:57 +00:00
this . network = _getNetwork ( networkType , currency ) ,
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
this . isTestnet = networkType = = bitcoin . testnet ,
2021-12-24 12:52:08 +00:00
super ( walletInfo ) {
this . electrumClient = electrumClient ? ? ElectrumClient ( ) ;
this . walletInfo = walletInfo ;
2023-10-12 22:50:16 +00:00
transactionHistory = ElectrumTransactionHistory ( walletInfo: walletInfo , password: password ) ;
2024-04-05 20:27:42 +00:00
reaction ( ( _ ) = > syncStatus , ( SyncStatus syncStatus ) {
silentPaymentsScanningActive = syncStatus is SyncingSyncStatus ;
} ) ;
2021-12-24 12:52:08 +00:00
}
2023-10-12 22:50:16 +00:00
static bitcoin . HDWallet bitcoinCashHDWallet ( Uint8List seedBytes ) = >
2023-11-15 23:12:23 +00:00
bitcoin . HDWallet . fromSeed ( seedBytes ) . derivePath ( " m/44'/145'/0'/0 " ) ;
2023-10-12 22:50:16 +00:00
2021-12-24 12:52:08 +00:00
static int estimatedTransactionSize ( int inputsCount , int outputsCounts ) = >
2023-12-13 14:43:26 +00:00
inputsCount * 68 + outputsCounts * 34 + 10 ;
2021-12-24 12:52:08 +00:00
final bitcoin . HDWallet hd ;
final String mnemonic ;
2024-01-23 05:15:24 +00:00
@ override
@ observable
bool isEnabledAutoGenerateSubaddress ;
2022-10-12 17:09:57 +00:00
late ElectrumClient electrumClient ;
2021-12-24 12:52:08 +00:00
Box < UnspentCoinsInfo > unspentCoinsInfo ;
@ override
2022-10-12 17:09:57 +00:00
late ElectrumWalletAddresses walletAddresses ;
2021-12-24 12:52:08 +00:00
@ override
@ observable
2022-10-12 17:09:57 +00:00
late ObservableMap < CryptoCurrency , ElectrumBalance > balance ;
2021-12-24 12:52:08 +00:00
@ override
@ observable
SyncStatus syncStatus ;
2024-02-27 14:40:56 +00:00
List < String > get scriptHashes = > walletAddresses . allAddresses
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
. map ( ( addr ) = > scriptHash ( addr . address , network: network ) )
2021-12-24 12:52:08 +00:00
. toList ( ) ;
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
List < String > get publicScriptHashes = > walletAddresses . allAddresses
2023-10-12 22:50:16 +00:00
. where ( ( addr ) = > ! addr . isHidden )
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
. map ( ( addr ) = > scriptHash ( addr . address , network: network ) )
2023-10-12 22:50:16 +00:00
. toList ( ) ;
2021-12-24 12:52:08 +00:00
2022-10-12 17:09:57 +00:00
String get xpub = > hd . base58 ! ;
2021-12-24 12:52:08 +00:00
@ override
String get seed = > mnemonic ;
bitcoin . NetworkType networkType ;
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
BasedUtxoNetwork network ;
@ override
bool ? isTestnet ;
2021-12-24 12:52:08 +00:00
2024-02-27 14:40:56 +00:00
@ observable
bool hasSilentPaymentsScanning = false ;
@ observable
bool nodeSupportsSilentPayments = true ;
2024-04-01 22:19:31 +00:00
@ observable
bool silentPaymentsScanningActive = false ;
@ action
2024-04-05 20:27:42 +00:00
void setSilentPaymentsScanning ( bool active ) {
silentPaymentsScanningActive = active ;
2024-04-01 22:19:31 +00:00
2024-04-05 20:27:42 +00:00
if ( active ) {
2024-04-01 22:19:31 +00:00
_setInitialHeight ( ) . then ( ( _ ) {
if ( ( currentChainTip ? ? 0 ) > walletInfo . restoreHeight ) {
_setListeners ( walletInfo . restoreHeight , chainTip: currentChainTip ) ;
}
} ) ;
} else {
_isolate ? . then ( ( runningIsolate ) = > runningIsolate . kill ( priority: Isolate . immediate ) ) ;
if ( electrumClient . isConnected ) {
syncStatus = SyncedSyncStatus ( ) ;
} else {
if ( electrumClient . uri ! = null ) {
electrumClient . connectToUri ( electrumClient . uri ! ) . then ( ( _ ) {
startSync ( ) ;
} ) ;
}
}
}
}
2024-02-27 14:40:56 +00:00
2024-02-27 22:51:53 +00:00
@ observable
int ? currentChainTip ;
2021-12-24 12:52:08 +00:00
@ override
2023-10-12 22:50:16 +00:00
BitcoinWalletKeys get keys = >
BitcoinWalletKeys ( wif: hd . wif ! , privateKey: hd . privKey ! , publicKey: hd . pubKey ! ) ;
2021-12-24 12:52:08 +00:00
2022-07-19 14:29:28 +00:00
String _password ;
2021-12-24 12:52:08 +00:00
List < BitcoinUnspent > unspentCoins ;
List < int > _feeRates ;
2022-10-12 17:09:57 +00:00
Map < String , BehaviorSubject < Object > ? > _scripthashesUpdateSubject ;
2024-02-26 18:32:54 +00:00
BehaviorSubject < Object > ? _chainTipUpdateSubject ;
2021-12-24 12:52:08 +00:00
bool _isTransactionUpdating ;
2024-02-26 18:33:31 +00:00
Future < Isolate > ? _isolate ;
2021-12-24 12:52:08 +00:00
2023-06-16 01:14:01 +00:00
void Function ( FlutterErrorDetails ) ? _onError ;
2024-02-26 18:32:54 +00:00
Timer ? _autoSaveTimer ;
static const int _autoSaveInterval = 30 ;
2023-06-16 01:14:01 +00:00
2021-12-24 12:52:08 +00:00
Future < void > init ( ) async {
await walletAddresses . init ( ) ;
await transactionHistory . init ( ) ;
2024-02-26 18:32:54 +00:00
_autoSaveTimer =
Timer . periodic ( Duration ( seconds: _autoSaveInterval ) , ( _ ) async = > await save ( ) ) ;
2021-12-24 12:52:08 +00:00
}
2024-02-26 18:33:31 +00:00
@ action
2024-04-09 15:15:21 +00:00
Future < void > _setListeners ( int height , { int ? chainTip , bool ? doSingleScan } ) async {
2024-02-26 18:33:31 +00:00
final currentChainTip = chainTip ? ? await electrumClient . getCurrentBlockChainTip ( ) ? ? 0 ;
syncStatus = AttemptingSyncStatus ( ) ;
if ( _isolate ! = null ) {
final runningIsolate = await _isolate ! ;
runningIsolate . kill ( priority: Isolate . immediate ) ;
}
final receivePort = ReceivePort ( ) ;
_isolate = Isolate . spawn (
startRefresh ,
ScanData (
sendPort: receivePort . sendPort ,
2024-03-01 23:38:53 +00:00
silentAddress: walletAddresses . silentAddress ! ,
2024-02-26 18:33:31 +00:00
network: network ,
height: height ,
chainTip: currentChainTip ,
electrumClient: ElectrumClient ( ) ,
transactionHistoryIds: transactionHistory . transactions . keys . toList ( ) ,
2024-04-05 22:20:18 +00:00
node: ScanNode ( node ! . uri , node ! . useSSL ) ,
2024-02-26 18:33:31 +00:00
labels: walletAddresses . labels ,
2024-04-09 15:15:21 +00:00
isSingleScan: doSingleScan ? ? false ,
2024-02-26 18:33:31 +00:00
) ) ;
await for ( var message in receivePort ) {
2024-02-27 22:51:53 +00:00
if ( message is Map < String , ElectrumTransactionInfo > ) {
for ( final map in message . entries ) {
final txid = map . key ;
final tx = map . value ;
if ( tx . unspents ! = null ) {
tx . unspents ! . forEach ( ( unspent ) = > walletAddresses . addSilentAddresses (
[ unspent . bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord ] ) ) ;
final existingTxInfo = transactionHistory . transactions [ txid ] ;
if ( existingTxInfo ! = null ) {
2024-04-10 21:05:36 +00:00
existingTxInfo . amount = tx . amount ;
existingTxInfo . confirmations = tx . confirmations ;
existingTxInfo . height = tx . height ;
2024-02-27 22:51:53 +00:00
final newUnspents = tx . unspents !
2024-03-01 23:38:53 +00:00
. where ( ( unspent ) = > ! ( existingTxInfo . unspents ? . any ( ( element ) = >
2024-04-10 21:05:36 +00:00
element . hash . contains ( unspent . hash ) & &
element . vout = = unspent . vout & &
element . value = = unspent . value ) ? ?
2024-03-01 23:38:53 +00:00
false ) )
2024-02-27 22:51:53 +00:00
. toList ( ) ;
if ( newUnspents . isNotEmpty ) {
existingTxInfo . unspents ? ? = [ ] ;
existingTxInfo . unspents ! . addAll ( newUnspents ) ;
2024-03-01 23:38:53 +00:00
final amount = newUnspents . length > 1
2024-02-27 22:51:53 +00:00
? newUnspents . map ( ( e ) = > e . value ) . reduce ( ( value , unspent ) = > value + unspent )
: newUnspents [ 0 ] . value ;
2024-03-01 23:38:53 +00:00
if ( existingTxInfo . direction = = TransactionDirection . incoming ) {
existingTxInfo . amount + = amount ;
} else {
existingTxInfo . amount = amount ;
existingTxInfo . direction = TransactionDirection . incoming ;
}
transactionHistory . addOne ( existingTxInfo ) ;
2024-02-27 22:51:53 +00:00
}
} else {
transactionHistory . addMany ( message ) ;
}
2024-03-01 23:38:53 +00:00
await transactionHistory . save ( ) ;
await updateUnspent ( ) ;
2024-03-11 12:46:20 +00:00
await updateBalance ( ) ;
2024-02-26 18:33:31 +00:00
}
}
}
// check if is a SyncStatus type since "is SyncStatus" doesn't work here
if ( message is SyncResponse ) {
2024-04-05 20:27:42 +00:00
if ( message . syncStatus is UnsupportedSyncStatus ) {
nodeSupportsSilentPayments = false ;
}
2024-02-26 18:33:31 +00:00
syncStatus = message . syncStatus ;
walletInfo . restoreHeight = message . height ;
await walletInfo . save ( ) ;
}
}
}
2024-02-26 18:32:54 +00:00
2021-12-24 12:52:08 +00:00
@ action
@ override
Future < void > startSync ( ) async {
try {
2024-02-27 22:51:53 +00:00
syncStatus = AttemptingSyncStatus ( ) ;
2024-04-10 21:05:36 +00:00
if ( hasSilentPaymentsScanning ) {
2024-02-27 14:40:56 +00:00
try {
await _setInitialHeight ( ) ;
} catch ( _ ) { }
2024-04-10 21:05:36 +00:00
}
2024-02-26 18:32:54 +00:00
2024-04-10 21:05:36 +00:00
if ( silentPaymentsScanningActive ) {
2024-02-28 15:48:42 +00:00
if ( ( currentChainTip ? ? 0 ) > walletInfo . restoreHeight ) {
2024-02-27 14:40:56 +00:00
_setListeners ( walletInfo . restoreHeight , chainTip: currentChainTip ) ;
}
}
2024-02-26 18:32:54 +00:00
2021-12-24 12:52:08 +00:00
await updateTransactions ( ) ;
_subscribeForUpdates ( ) ;
await updateUnspent ( ) ;
2023-04-20 13:46:41 +00:00
await updateBalance ( ) ;
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
_feeRates = await electrumClient . feeRates ( network: network ) ;
2021-12-24 12:52:08 +00:00
2023-10-12 22:50:16 +00:00
Timer . periodic (
const Duration ( minutes: 1 ) , ( timer ) async = > _feeRates = await electrumClient . feeRates ( ) ) ;
2021-12-24 12:52:08 +00:00
2024-04-01 22:19:31 +00:00
if ( ! silentPaymentsScanningActive | | walletInfo . restoreHeight = = currentChainTip ) {
2024-02-27 22:51:53 +00:00
syncStatus = SyncedSyncStatus ( ) ;
}
2022-10-12 17:09:57 +00:00
} catch ( e , stacktrace ) {
print ( stacktrace ) ;
2021-12-24 12:52:08 +00:00
print ( e . toString ( ) ) ;
syncStatus = FailedSyncStatus ( ) ;
}
}
2024-04-05 20:27:42 +00:00
Node ? node ;
2021-12-24 12:52:08 +00:00
@ action
2024-04-09 23:35:00 +00:00
@ override
Future < void > connectToNode ( { required Node node } ) async {
2024-04-05 20:27:42 +00:00
this . node = node ;
2021-12-24 12:52:08 +00:00
try {
syncStatus = ConnectingSyncStatus ( ) ;
2024-04-09 23:35:00 +00:00
if ( ! electrumClient . isConnected ) {
await electrumClient . close ( ) ;
}
2024-02-28 15:48:42 +00:00
electrumClient . onConnectionStatusChange = ( bool isConnected ) async {
2024-04-09 23:35:00 +00:00
if ( isConnected ) {
syncStatus = ConnectedSyncStatus ( ) ;
} else if ( isConnected = = false ) {
2021-12-24 12:52:08 +00:00
syncStatus = LostConnectionSyncStatus ( ) ;
}
} ;
2024-04-09 23:35:00 +00:00
await electrumClient . connectToUri ( node . uri , useSSL: node . useSSL ) ;
2021-12-24 12:52:08 +00:00
} catch ( e ) {
print ( e . toString ( ) ) ;
syncStatus = FailedSyncStatus ( ) ;
}
}
2024-04-08 14:54:58 +00:00
int get _dustAmount = > 546 ;
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
2024-04-08 14:54:58 +00:00
bool _isBelowDust ( int amount ) = > amount < = _dustAmount & & network ! = BitcoinNetwork . testnet ;
2024-03-29 18:51:34 +00:00
2024-04-05 20:27:42 +00:00
void _createSilentPayments (
List < BitcoinOutput > outputs ,
List < ECPublic > inputPubKeys ,
List < Outpoint > vinOutpoints ,
List < ECPrivateInfo > inputPrivKeyInfos ,
) {
List < SilentPaymentDestination > silentPaymentDestinations = [ ] ;
for ( final out in outputs ) {
final address = out . address ;
final amount = out . value ;
if ( address is SilentPaymentAddress ) {
silentPaymentDestinations . add (
SilentPaymentDestination . fromAddress ( address . toAddress ( network ) , amount . toInt ( ) ) ,
) ;
}
}
if ( silentPaymentDestinations . isNotEmpty ) {
final spb = SilentPaymentBuilder ( pubkeys: inputPubKeys , outpoints: vinOutpoints ) ;
final sendingOutputs = spb . createOutputs ( inputPrivKeyInfos , silentPaymentDestinations ) ;
final outputsAdded = [ ] ;
for ( var i = 0 ; i < outputs . length ; i + + ) {
final out = outputs [ i ] ;
final silentOutputs = sendingOutputs [ out . address . toAddress ( network ) ] ;
if ( silentOutputs ! = null ) {
final silentOutput =
silentOutputs . firstWhereOrNull ( ( element ) = > ! outputsAdded . contains ( element ) ) ;
if ( silentOutput ! = null ) {
outputs [ i ] = BitcoinOutput (
address: silentOutput . address ,
value: BigInt . from ( silentOutput . amount ) ,
) ;
outputsAdded . add ( silentOutput ) ;
}
}
}
}
}
2024-03-29 18:51:34 +00:00
Future < EstimatedTxResult > estimateSendAllTx (
List < BitcoinOutput > outputs ,
int feeRate , {
String ? memo ,
int credentialsAmount = 0 ,
2024-04-01 21:07:49 +00:00
bool hasSilentPayment = false ,
2024-03-29 18:51:34 +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 utxos = < UtxoWithAddress > [ ] ;
2024-03-29 18:51:34 +00:00
int allInputsAmount = 0 ;
2021-12-24 12:52:08 +00:00
2024-02-27 14:40:56 +00:00
List < Outpoint > vinOutpoints = [ ] ;
List < ECPrivateInfo > inputPrivKeyInfos = [ ] ;
List < ECPublic > inputPubKeys = [ ] ;
2024-03-05 14:54:40 +00:00
bool spendsSilentPayment = false ;
2024-04-10 21:05:36 +00:00
bool spendsCPFP = false ;
2024-02-27 14:40:56 +00:00
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
for ( int i = 0 ; i < unspentCoins . length ; i + + ) {
final utx = unspentCoins [ i ] ;
2021-12-24 12:52:08 +00:00
if ( utx . isSending ) {
2024-04-10 21:05:36 +00:00
spendsCPFP = utx . confirmations = = 0 ;
2021-12-24 12:52:08 +00:00
allInputsAmount + = utx . value ;
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
2024-03-21 02:51:57 +00:00
final address = addressTypeFromStr ( utx . address , network ) ;
2024-02-27 22:51:53 +00:00
ECPrivate ? privkey ;
2024-03-11 12:46:20 +00:00
bool ? isSilentPayment = false ;
2024-04-01 21:07:49 +00:00
2024-02-27 22:51:53 +00:00
if ( utx . bitcoinAddressRecord is BitcoinSilentPaymentAddressRecord ) {
2024-03-11 12:46:20 +00:00
privkey = walletAddresses . silentAddress ! . b_spend . tweakAdd (
2024-04-01 21:07:49 +00:00
BigintUtils . fromBytes (
BytesUtils . fromHexString (
( utx . bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord ) . silentPaymentTweak ! ,
) ,
) ,
2024-03-11 12:46:20 +00:00
) ;
2024-03-05 14:54:40 +00:00
spendsSilentPayment = true ;
2024-03-11 12:46:20 +00:00
isSilentPayment = true ;
2024-02-27 22:51:53 +00:00
} else {
privkey = generateECPrivate (
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
hd: utx . bitcoinAddressRecord . isHidden ? walletAddresses . sideHd : walletAddresses . mainHd ,
index: utx . bitcoinAddressRecord . index ,
2024-04-01 21:07:49 +00:00
network: network ,
) ;
2024-02-27 22:51:53 +00:00
}
2024-02-26 18:32:54 +00:00
2024-02-27 14:40:56 +00:00
inputPrivKeyInfos . add ( ECPrivateInfo ( privkey , address . type = = SegwitAddresType . p2tr ) ) ;
inputPubKeys . add ( privkey . getPublic ( ) ) ;
vinOutpoints . add ( Outpoint ( txid: utx . hash , index: utx . vout ) ) ;
2024-02-26 18:32:54 +00:00
utxos . add (
UtxoWithAddress (
utxo: BitcoinUtxo (
txHash: utx . hash ,
value: BigInt . from ( utx . value ) ,
vout: utx . vout ,
scriptType: _getScriptType ( address ) ,
2024-03-11 12:46:20 +00:00
isSilentPayment: isSilentPayment ,
2024-02-26 18:32:54 +00:00
) ,
2024-03-29 18:51:34 +00:00
ownerDetails: UtxoAddressDetails (
publicKey: privkey . getPublic ( ) . toHex ( ) ,
address: address ,
) ,
2024-02-26 18:32:54 +00:00
) ,
) ;
}
}
2024-02-27 14:40:56 +00:00
if ( utxos . isEmpty ) {
2024-02-26 18:32:54 +00:00
throw BitcoinTransactionNoInputsException ( ) ;
}
2024-04-05 20:27:42 +00:00
if ( hasSilentPayment = = true ) {
_createSilentPayments ( outputs , inputPubKeys , vinOutpoints , inputPrivKeyInfos ) ;
}
2024-03-29 18:51:34 +00:00
int estimatedSize ;
if ( network is BitcoinCashNetwork ) {
estimatedSize = ForkedTransactionBuilder . estimateTransactionSize (
utxos: utxos ,
outputs: outputs ,
network: network as BitcoinCashNetwork ,
memo: memo ,
) ;
} else {
estimatedSize = BitcoinTransactionBuilder . estimateTransactionSize (
utxos: utxos ,
outputs: outputs ,
network: network ,
memo: memo ,
) ;
2024-02-26 18:32:54 +00:00
}
2024-03-29 18:51:34 +00:00
int fee = feeAmountWithFeeRate ( feeRate , 0 , 0 , size: estimatedSize ) ;
2021-12-24 12:52:08 +00:00
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
if ( fee = = 0 ) {
2024-03-29 18:51:34 +00:00
throw BitcoinTransactionNoFeeException ( ) ;
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
}
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
// Here, when sending all, the output amount equals to the input value - fee to fully spend every input on the transaction and have no amount left for change
int amount = allInputsAmount - fee ;
2022-07-28 17:03:16 +00:00
2024-03-29 18:51:34 +00:00
// Attempting to send less than the dust limit
if ( _isBelowDust ( amount ) ) {
throw BitcoinTransactionNoDustException ( ) ;
}
if ( credentialsAmount > 0 ) {
final amountLeftForFee = amount - credentialsAmount ;
if ( amountLeftForFee > 0 & & _isBelowDust ( amountLeftForFee ) ) {
amount - = amountLeftForFee ;
fee + = amountLeftForFee ;
2022-07-28 17:03:16 +00:00
}
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
}
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
outputs [ outputs . length - 1 ] =
BitcoinOutput ( address: outputs . last . address , value: BigInt . from ( amount ) ) ;
return EstimatedTxResult (
2024-03-28 12:41:11 +00:00
utxos: utxos ,
2024-04-01 21:07:49 +00:00
inputPrivKeyInfos: inputPrivKeyInfos ,
2024-03-29 18:51:34 +00:00
fee: fee ,
amount: amount ,
isSendAll: true ,
hasChange: false ,
2024-03-28 12:41:11 +00:00
memo: memo ,
2024-04-01 21:07:49 +00:00
spendsSilentPayment: spendsSilentPayment ,
2024-04-10 21:05:36 +00:00
spendsCPFP: spendsCPFP ,
2024-03-28 12:41:11 +00:00
) ;
2024-03-29 18:51:34 +00:00
}
2022-07-28 17:03:16 +00:00
2024-03-29 18:51:34 +00:00
Future < EstimatedTxResult > estimateTxForAmount (
int credentialsAmount ,
List < BitcoinOutput > outputs ,
int feeRate , {
int ? inputsCount ,
String ? memo ,
2024-04-01 21:07:49 +00:00
bool hasSilentPayment = false ,
2024-03-29 18:51:34 +00:00
} ) async {
final utxos = < UtxoWithAddress > [ ] ;
2024-04-05 20:27:42 +00:00
List < Outpoint > vinOutpoints = [ ] ;
2024-04-01 21:07:49 +00:00
List < ECPrivateInfo > inputPrivKeyInfos = [ ] ;
2024-04-05 20:27:42 +00:00
List < ECPublic > inputPubKeys = [ ] ;
2024-03-29 18:51:34 +00:00
int allInputsAmount = 0 ;
2024-04-01 21:07:49 +00:00
bool spendsSilentPayment = false ;
2024-04-10 21:05:36 +00:00
bool spendsCPFP = false ;
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
int leftAmount = credentialsAmount ;
final sendingCoins = unspentCoins . where ( ( utx ) = > utx . isSending ) . toList ( ) ;
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
for ( int i = 0 ; i < sendingCoins . length ; i + + ) {
final utx = sendingCoins [ i ] ;
2024-04-10 21:05:36 +00:00
spendsCPFP = utx . confirmations = = 0 ;
2022-07-28 17:03:16 +00:00
2024-03-29 18:51:34 +00:00
allInputsAmount + = utx . value ;
leftAmount = leftAmount - utx . value ;
final address = addressTypeFromStr ( utx . address , network ) ;
2024-04-01 21:07:49 +00:00
ECPrivate ? privkey ;
bool ? isSilentPayment = false ;
if ( utx . bitcoinAddressRecord is BitcoinSilentPaymentAddressRecord ) {
privkey = walletAddresses . silentAddress ! . b_spend . tweakAdd (
BigintUtils . fromBytes (
BytesUtils . fromHexString (
( utx . bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord ) . silentPaymentTweak ! ,
) ,
) ,
) ;
spendsSilentPayment = true ;
isSilentPayment = true ;
} else {
privkey = generateECPrivate (
2024-03-29 18:51:34 +00:00
hd: utx . bitcoinAddressRecord . isHidden ? walletAddresses . sideHd : walletAddresses . mainHd ,
index: utx . bitcoinAddressRecord . index ,
2024-04-01 21:07:49 +00:00
network: network ,
) ;
}
2024-03-29 18:51:34 +00:00
2024-04-05 20:27:42 +00:00
inputPrivKeyInfos . add ( ECPrivateInfo ( privkey , address . type = = SegwitAddresType . p2tr ) ) ;
inputPubKeys . add ( privkey . getPublic ( ) ) ;
vinOutpoints . add ( Outpoint ( txid: utx . hash , index: utx . vout ) ) ;
2024-03-29 18:51:34 +00:00
utxos . add (
UtxoWithAddress (
utxo: BitcoinUtxo (
txHash: utx . hash ,
value: BigInt . from ( utx . value ) ,
vout: utx . vout ,
scriptType: _getScriptType ( address ) ,
2024-04-01 21:07:49 +00:00
isSilentPayment: isSilentPayment ,
2024-03-29 18:51:34 +00:00
) ,
ownerDetails: UtxoAddressDetails (
publicKey: privkey . getPublic ( ) . toHex ( ) ,
address: address ,
) ,
) ,
) ;
bool amountIsAcquired = leftAmount < = 0 ;
if ( ( inputsCount = = null & & amountIsAcquired ) | | inputsCount = = i + 1 ) {
break ;
2022-07-28 17:03:16 +00:00
}
2024-03-29 18:51:34 +00:00
}
if ( utxos . isEmpty ) {
throw BitcoinTransactionNoInputsException ( ) ;
}
2024-04-05 20:27:42 +00:00
if ( hasSilentPayment = = true ) {
_createSilentPayments ( outputs , inputPubKeys , vinOutpoints , inputPrivKeyInfos ) ;
}
2024-03-29 18:51:34 +00:00
final spendingAllCoins = sendingCoins . length = = utxos . length ;
// How much is being spent - how much is being sent
int amountLeftForChangeAndFee = allInputsAmount - credentialsAmount ;
if ( amountLeftForChangeAndFee < = 0 ) {
throw BitcoinTransactionWrongBalanceException ( ) ;
}
final changeAddress = await walletAddresses . getChangeAddress ( ) ;
final address = addressTypeFromStr ( changeAddress , network ) ;
outputs . add ( BitcoinOutput (
address: address ,
value: BigInt . from ( amountLeftForChangeAndFee ) ,
) ) ;
int estimatedSize ;
if ( network is BitcoinCashNetwork ) {
estimatedSize = ForkedTransactionBuilder . estimateTransactionSize (
utxos: utxos ,
outputs: outputs ,
network: network as BitcoinCashNetwork ,
memo: memo ,
) ;
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
} else {
2024-03-29 18:51:34 +00:00
estimatedSize = BitcoinTransactionBuilder . estimateTransactionSize (
utxos: utxos ,
outputs: outputs ,
network: network ,
memo: memo ,
) ;
}
int fee = feeAmountWithFeeRate ( feeRate , 0 , 0 , size: estimatedSize ) ;
if ( fee = = 0 ) {
throw BitcoinTransactionNoFeeException ( ) ;
}
int amount = credentialsAmount ;
final lastOutput = outputs . last ;
final amountLeftForChange = amountLeftForChangeAndFee - fee ;
if ( ! _isBelowDust ( amountLeftForChange ) ) {
// Here, lastOutput already is change, return the amount left without the fee to the user's address.
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
outputs [ outputs . length - 1 ] =
2024-03-29 18:51:34 +00:00
BitcoinOutput ( address: lastOutput . address , value: BigInt . from ( amountLeftForChange ) ) ;
} else {
// If has change that is lower than dust, will end up with tx rejected by network rules, so estimate again without the added change
outputs . removeLast ( ) ;
// Still has inputs to spend before failing
if ( ! spendingAllCoins ) {
return estimateTxForAmount (
credentialsAmount ,
outputs ,
feeRate ,
inputsCount: utxos . length + 1 ,
memo: memo ,
) ;
}
final estimatedSendAll = await estimateSendAllTx (
outputs ,
feeRate ,
memo: memo ,
) ;
if ( estimatedSendAll . amount = = credentialsAmount ) {
return estimatedSendAll ;
}
// Estimate to user how much is needed to send to cover the fee
2024-04-08 14:54:58 +00:00
final maxAmountWithReturningChange = allInputsAmount - _dustAmount - fee - 1 ;
2024-03-29 18:51:34 +00:00
throw BitcoinTransactionNoDustOnChangeException (
bitcoinAmountToString ( amount: maxAmountWithReturningChange ) ,
bitcoinAmountToString ( amount: estimatedSendAll . amount ) ,
) ;
}
// Attempting to send less than the dust limit
if ( _isBelowDust ( amount ) ) {
throw BitcoinTransactionNoDustException ( ) ;
2021-12-24 12:52:08 +00:00
}
final totalAmount = amount + fee ;
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
if ( totalAmount > balance [ currency ] ! . confirmed ) {
2024-03-29 18:51:34 +00:00
throw BitcoinTransactionWrongBalanceException ( ) ;
2021-12-24 12:52:08 +00:00
}
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
if ( totalAmount > allInputsAmount ) {
2024-03-29 18:51:34 +00:00
if ( spendingAllCoins ) {
throw BitcoinTransactionWrongBalanceException ( ) ;
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
} else {
2024-03-29 18:51:34 +00:00
if ( amountLeftForChangeAndFee > fee ) {
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
outputs . removeLast ( ) ;
2021-12-24 12:52:08 +00:00
}
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
2024-03-29 18:51:34 +00:00
return estimateTxForAmount (
credentialsAmount ,
outputs ,
feeRate ,
inputsCount: utxos . length + 1 ,
memo: memo ,
2024-04-01 21:07:49 +00:00
hasSilentPayment: hasSilentPayment ,
2024-03-29 18:51:34 +00:00
) ;
2021-12-24 12:52:08 +00:00
}
}
2024-03-05 14:54:40 +00:00
return EstimatedTxResult (
2024-03-28 12:41:11 +00:00
utxos: utxos ,
2024-04-01 21:07:49 +00:00
inputPrivKeyInfos: inputPrivKeyInfos ,
2024-03-28 12:41:11 +00:00
fee: fee ,
amount: amount ,
2024-03-29 18:51:34 +00:00
hasChange: true ,
isSendAll: false ,
2024-03-28 12:41:11 +00:00
memo: memo ,
2024-04-01 21:07:49 +00:00
spendsSilentPayment: spendsSilentPayment ,
2024-04-10 21:05:36 +00:00
spendsCPFP: spendsCPFP ,
2024-03-28 12:41:11 +00:00
) ;
2024-02-27 14:40:56 +00:00
}
@ override
Future < PendingTransaction > createTransaction ( Object credentials ) async {
try {
final outputs = < BitcoinOutput > [ ] ;
final transactionCredentials = credentials as BitcoinTransactionCredentials ;
final hasMultiDestination = transactionCredentials . outputs . length > 1 ;
final sendAll = ! hasMultiDestination & & transactionCredentials . outputs . first . sendAll ;
2024-03-29 18:51:34 +00:00
final memo = transactionCredentials . outputs . first . memo ;
2024-02-27 14:40:56 +00:00
2024-03-29 18:51:34 +00:00
int credentialsAmount = 0 ;
2024-02-27 14:40:56 +00:00
bool hasSilentPayment = false ;
for ( final out in transactionCredentials . outputs ) {
2024-03-29 18:51:34 +00:00
final outputAmount = out . formattedCryptoAmount ! ;
2024-02-27 14:40:56 +00:00
2024-03-29 18:51:34 +00:00
if ( ! sendAll & & _isBelowDust ( outputAmount ) ) {
throw BitcoinTransactionNoDustException ( ) ;
2024-02-26 18:32:54 +00:00
}
2021-12-24 12:52:08 +00:00
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
if ( hasMultiDestination ) {
2024-03-29 18:51:34 +00:00
if ( out . sendAll ) {
throw BitcoinTransactionWrongBalanceException ( ) ;
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
}
2024-03-29 18:51:34 +00:00
}
2023-06-16 01:14:01 +00:00
2024-03-29 18:51:34 +00:00
credentialsAmount + = outputAmount ;
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
final address =
addressTypeFromStr ( out . isParsedAddress ? out . extractedAddress ! : out . address , network ) ;
2024-04-01 21:07:49 +00:00
if ( address is SilentPaymentAddress ) {
hasSilentPayment = true ;
}
2024-03-29 18:51:34 +00:00
if ( sendAll ) {
// The value will be changed after estimating the Tx size and deducting the fee from the total to be sent
outputs . add ( BitcoinOutput ( address: address , value: BigInt . from ( 0 ) ) ) ;
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
} else {
2024-03-29 18:51:34 +00:00
outputs . add ( BitcoinOutput ( address: address , value: BigInt . from ( outputAmount ) ) ) ;
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
}
}
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
final feeRateInt = transactionCredentials . feeRate ! = null
? transactionCredentials . feeRate !
: feeRate ( transactionCredentials . priority ! ) ;
EstimatedTxResult estimatedTx ;
if ( sendAll ) {
estimatedTx = await estimateSendAllTx (
outputs ,
feeRateInt ,
memo: memo ,
credentialsAmount: credentialsAmount ,
2024-04-01 21:07:49 +00:00
hasSilentPayment: hasSilentPayment ,
2024-03-29 18:51:34 +00:00
) ;
} else {
estimatedTx = await estimateTxForAmount (
credentialsAmount ,
outputs ,
feeRateInt ,
memo: memo ,
2024-04-01 21:07:49 +00:00
hasSilentPayment: hasSilentPayment ,
2024-03-29 18:51:34 +00:00
) ;
}
2021-12-24 12:52:08 +00:00
2024-03-29 18:51:34 +00:00
BasedBitcoinTransacationBuilder txb ;
if ( network is BitcoinCashNetwork ) {
txb = ForkedTransactionBuilder (
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
utxos: estimatedTx . utxos ,
outputs: outputs ,
fee: BigInt . from ( estimatedTx . fee ) ,
2024-03-29 18:51:34 +00:00
network: network ,
memo: estimatedTx . memo ,
outputOrdering: BitcoinOrdering . none ,
2024-04-10 21:05:36 +00:00
enableRBF: ! estimatedTx . spendsCPFP ,
2024-03-29 18:51:34 +00:00
) ;
} else {
txb = BitcoinTransactionBuilder (
utxos: estimatedTx . utxos ,
outputs: outputs ,
fee: BigInt . from ( estimatedTx . fee ) ,
network: network ,
memo: estimatedTx . memo ,
outputOrdering: BitcoinOrdering . none ,
2024-04-10 21:05:36 +00:00
enableRBF: ! estimatedTx . spendsCPFP ,
2024-03-29 18:51:34 +00:00
) ;
}
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
2024-04-01 13:31:14 +00:00
bool hasTaprootInputs = false ;
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 transaction = txb . buildTransaction ( ( txDigest , utxo , publicKey , sighash ) {
2024-03-11 12:46:20 +00:00
final key = estimatedTx . inputPrivKeyInfos
. firstWhereOrNull ( ( element ) = > element . privkey . getPublic ( ) . toHex ( ) = = publicKey ) ;
2021-12-24 12:52:08 +00:00
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
if ( key = = null ) {
throw Exception ( " Cannot find private key " ) ;
}
if ( utxo . utxo . isP2tr ( ) ) {
2024-04-01 13:31:14 +00:00
hasTaprootInputs = true ;
2024-03-11 12:46:20 +00:00
return key . privkey . signTapRoot (
txDigest ,
sighash: sighash ,
tweak: utxo . utxo . isSilentPayment ! = true ,
) ;
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
} else {
2024-03-11 12:46:20 +00:00
return key . privkey . signInput ( txDigest , sigHash: sighash ) ;
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
}
2021-12-24 12:52:08 +00:00
} ) ;
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
2024-04-01 13:31:14 +00:00
return PendingBitcoinTransaction (
transaction ,
type ,
electrumClient: electrumClient ,
amount: estimatedTx . amount ,
fee: estimatedTx . fee ,
feeRate: feeRateInt . toString ( ) ,
network: network ,
hasChange: estimatedTx . hasChange ,
isSendAll: estimatedTx . isSendAll ,
hasTaprootInputs: hasTaprootInputs ,
) . . addListener ( ( transaction ) 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
transactionHistory . addOne ( transaction ) ;
2024-03-05 14:54:40 +00:00
if ( estimatedTx . spendsSilentPayment ) {
transactionHistory . transactions . values . forEach ( ( tx ) {
tx . unspents ? . removeWhere (
( unspent ) = > estimatedTx . utxos . any ( ( e ) = > e . utxo . txHash = = unspent . hash ) ) ;
transactionHistory . addOne ( tx ) ;
} ) ;
}
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
await updateBalance ( ) ;
} ) ;
} catch ( e ) {
throw e ;
}
2021-12-24 12:52:08 +00:00
}
String toJSON ( ) = > json . encode ( {
2023-11-15 23:12:23 +00:00
' mnemonic ' : mnemonic ,
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
' account_index ' : walletAddresses . currentReceiveAddressIndexByType ,
' change_address_index ' : walletAddresses . currentChangeAddressIndexByType ,
' addresses ' : walletAddresses . allAddresses . map ( ( addr ) = > addr . toJSON ( ) ) . toList ( ) ,
' address_page_type ' : walletInfo . addressPageType = = null
? SegwitAddresType . p2wpkh . toString ( )
: walletInfo . addressPageType . toString ( ) ,
' balance ' : balance [ currency ] ? . toJSON ( ) ,
2024-02-26 18:32:54 +00:00
' silent_addresses ' : walletAddresses . silentAddresses . map ( ( addr ) = > addr . toJSON ( ) ) . toList ( ) ,
' silent_address_index ' : walletAddresses . currentSilentAddressIndex . toString ( ) ,
2023-11-15 23:12:23 +00:00
} ) ;
2021-12-24 12:52:08 +00:00
int feeRate ( TransactionPriority priority ) {
2022-01-13 14:48:42 +00:00
try {
if ( priority is BitcoinTransactionPriority ) {
return _feeRates [ priority . raw ] ;
}
2021-12-24 12:52:08 +00:00
2022-01-13 14:48:42 +00:00
return 0 ;
2023-10-12 22:50:16 +00:00
} catch ( _ ) {
2022-01-13 14:48:42 +00:00
return 0 ;
}
2021-12-24 12:52:08 +00:00
}
2024-03-29 18:51:34 +00:00
int feeAmountForPriority ( TransactionPriority priority , int inputsCount , int outputsCount ,
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
{ int ? size } ) = >
feeRate ( priority ) * ( size ? ? estimatedTransactionSize ( inputsCount , outputsCount ) ) ;
2021-12-24 12:52:08 +00:00
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
int feeAmountWithFeeRate ( int feeRate , int inputsCount , int outputsCount , { int ? size } ) = >
feeRate * ( size ? ? estimatedTransactionSize ( inputsCount , outputsCount ) ) ;
2022-07-28 17:03:16 +00:00
2021-12-24 12:52:08 +00:00
@ override
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
int calculateEstimatedFee ( TransactionPriority ? priority , int ? amount ,
{ int ? outputsCount , int ? size } ) {
2021-12-24 12:52:08 +00:00
if ( priority is BitcoinTransactionPriority ) {
2023-10-12 22:50:16 +00:00
return calculateEstimatedFeeWithFeeRate ( feeRate ( priority ) , amount ,
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
outputsCount: outputsCount , size: size ) ;
2022-07-28 17:03:16 +00:00
}
2021-12-24 12:52:08 +00:00
2022-07-28 17:03:16 +00:00
return 0 ;
}
2021-12-24 12:52:08 +00:00
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
int calculateEstimatedFeeWithFeeRate ( int feeRate , int ? amount , { int ? outputsCount , int ? size } ) {
if ( size ! = null ) {
return feeAmountWithFeeRate ( feeRate , 0 , 0 , size: size ) ;
}
2022-07-28 17:03:16 +00:00
int inputsCount = 0 ;
2021-12-24 12:52:08 +00:00
2022-07-28 17:03:16 +00:00
if ( amount ! = null ) {
int totalValue = 0 ;
for ( final input in unspentCoins ) {
if ( totalValue > = amount ) {
break ;
2021-12-24 12:52:08 +00:00
}
2022-07-28 17:03:16 +00:00
if ( input . isSending ) {
totalValue + = input . value ;
inputsCount + = 1 ;
2021-12-24 12:52:08 +00:00
}
}
2022-07-28 17:03:16 +00:00
if ( totalValue < amount ) return 0 ;
} else {
for ( final input in unspentCoins ) {
if ( input . isSending ) {
inputsCount + = 1 ;
}
}
2021-12-24 12:52:08 +00:00
}
2022-07-28 17:03:16 +00:00
// If send all, then we have no change value
final _outputsCount = outputsCount ? ? ( amount ! = null ? 2 : 1 ) ;
2023-10-12 22:50:16 +00:00
return feeAmountWithFeeRate ( feeRate , inputsCount , _outputsCount ) ;
2021-12-24 12:52:08 +00:00
}
@ override
Future < void > save ( ) async {
final path = await makePath ( ) ;
await write ( path: path , password: _password , data: toJSON ( ) ) ;
await transactionHistory . save ( ) ;
}
2023-08-04 17:01:49 +00:00
@ override
2023-07-12 23:20:11 +00:00
Future < void > renameWalletFiles ( String newWalletName ) async {
final currentWalletPath = await pathForWallet ( name: walletInfo . name , type: type ) ;
final currentWalletFile = File ( currentWalletPath ) ;
2023-10-12 22:50:16 +00:00
final currentDirPath = await pathForWalletDir ( name: walletInfo . name , type: type ) ;
2023-07-12 23:20:11 +00:00
final currentTransactionsFile = File ( ' $ currentDirPath / $ transactionsHistoryFileName ' ) ;
// Copies current wallet files into new wallet name's dir and files
if ( currentWalletFile . existsSync ( ) ) {
final newWalletPath = await pathForWallet ( name: newWalletName , type: type ) ;
await currentWalletFile . copy ( newWalletPath ) ;
}
if ( currentTransactionsFile . existsSync ( ) ) {
final newDirPath = await pathForWalletDir ( name: newWalletName , type: type ) ;
await currentTransactionsFile . copy ( ' $ newDirPath / $ transactionsHistoryFileName ' ) ;
}
// Delete old name's dir and files
await Directory ( currentDirPath ) . delete ( recursive: true ) ;
}
2022-07-19 14:29:28 +00:00
@ override
Future < void > changePassword ( String password ) async {
_password = password ;
await save ( ) ;
await transactionHistory . changePassword ( password ) ;
}
2024-04-05 20:27:42 +00:00
@ action
2021-12-24 12:52:08 +00:00
@ override
2024-04-09 15:15:21 +00:00
Future < void > rescan (
{ required int height , int ? chainTip , ScanData ? scanData , bool ? doSingleScan } ) async {
2024-04-05 20:27:42 +00:00
silentPaymentsScanningActive = true ;
2024-04-09 15:15:21 +00:00
_setListeners ( height , doSingleScan: doSingleScan ) ;
2024-02-26 18:32:54 +00:00
}
2021-12-24 12:52:08 +00:00
@ override
Future < void > close ( ) async {
try {
2022-10-12 17:09:57 +00:00
await electrumClient . close ( ) ;
2021-12-24 12:52:08 +00:00
} catch ( _ ) { }
2024-02-26 18:32:54 +00:00
_autoSaveTimer ? . cancel ( ) ;
2021-12-24 12:52:08 +00:00
}
2023-10-12 22:50:16 +00:00
Future < String > makePath ( ) async = > pathForWallet ( name: walletInfo . name , type: walletInfo . type ) ;
2021-12-24 12:52:08 +00:00
Future < void > updateUnspent ( ) async {
2024-02-27 22:51:53 +00:00
List < BitcoinUnspent > updatedUnspentCoins = [ ] ;
2024-04-01 21:07:49 +00:00
if ( hasSilentPaymentsScanning ) {
// Update unspents stored from scanned silent payment transactions
transactionHistory . transactions . values . forEach ( ( tx ) {
if ( tx . unspents ! = null ) {
updatedUnspentCoins . addAll ( tx . unspents ! ) ;
}
} ) ;
}
2024-02-26 18:32:54 +00:00
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 addressesSet = walletAddresses . allAddresses . map ( ( addr ) = > addr . address ) . toSet ( ) ;
await Future . wait ( walletAddresses . allAddresses . map ( ( address ) = > electrumClient
. getListUnspentWithAddress ( address . address , network )
. then ( ( unspent ) = > Future . forEach < Map < String , dynamic > > ( unspent , ( unspent ) async {
2023-11-15 23:12:23 +00:00
try {
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 coin = BitcoinUnspent . fromJSON ( address , unspent ) ;
final tx = await fetchTransactionInfo (
hash: coin . hash , height: 0 , myAddresses: addressesSet ) ;
coin . isChange = tx ? . direction = = TransactionDirection . outgoing ;
2024-04-10 21:05:36 +00:00
coin . confirmations = tx ? . confirmations ;
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
updatedUnspentCoins . add ( coin ) ;
} catch ( _ ) { }
} ) ) ) ) ;
unspentCoins = updatedUnspentCoins ;
2021-12-24 12:52:08 +00:00
if ( unspentCoinsInfo . isEmpty ) {
unspentCoins . forEach ( ( coin ) = > _addCoinInfo ( coin ) ) ;
return ;
}
if ( unspentCoins . isNotEmpty ) {
unspentCoins . forEach ( ( coin ) {
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 coinInfoList = unspentCoinsInfo . values . where ( ( element ) = >
element . walletId . contains ( id ) & &
element . hash . contains ( coin . hash ) & &
2024-02-27 14:40:56 +00:00
element . vout = = coin . vout ) ;
2021-12-24 12:52:08 +00:00
if ( coinInfoList . isNotEmpty ) {
final coinInfo = coinInfoList . first ;
coin . isFrozen = coinInfo . isFrozen ;
coin . isSending = coinInfo . isSending ;
coin . note = coinInfo . note ;
} else {
_addCoinInfo ( coin ) ;
}
} ) ;
}
await _refreshUnspentCoinsInfo ( ) ;
}
2024-02-26 18:32:54 +00:00
@ action
2021-12-24 12:52:08 +00:00
Future < void > _addCoinInfo ( BitcoinUnspent coin ) async {
final newInfo = UnspentCoinsInfo (
2023-10-12 22:50:16 +00:00
walletId: id ,
hash: coin . hash ,
isFrozen: coin . isFrozen ,
isSending: coin . isSending ,
noteRaw: coin . note ,
address: coin . bitcoinAddressRecord . address ,
value: coin . value ,
vout: coin . vout ,
2023-11-15 23:12:23 +00:00
isChange: coin . isChange ,
2021-12-24 12:52:08 +00:00
) ;
await unspentCoinsInfo . add ( newInfo ) ;
}
Future < void > _refreshUnspentCoinsInfo ( ) async {
try {
final List < dynamic > keys = < dynamic > [ ] ;
2023-10-12 22:50:16 +00:00
final currentWalletUnspentCoins =
2023-11-15 23:12:23 +00:00
unspentCoinsInfo . values . where ( ( element ) = > element . walletId . contains ( id ) ) ;
2021-12-24 12:52:08 +00:00
if ( currentWalletUnspentCoins . isNotEmpty ) {
currentWalletUnspentCoins . forEach ( ( element ) {
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 existUnspentCoins = unspentCoins
. where ( ( coin ) = > element . hash . contains ( coin . hash ) & & element . vout = = coin . vout ) ;
2021-12-24 12:52:08 +00:00
2022-10-12 17:09:57 +00:00
if ( existUnspentCoins . isEmpty ) {
2021-12-24 12:52:08 +00:00
keys . add ( element . key ) ;
}
} ) ;
}
if ( keys . isNotEmpty ) {
await unspentCoinsInfo . deleteAll ( keys ) ;
}
} catch ( e ) {
print ( e . toString ( ) ) ;
}
}
2024-04-08 14:54:58 +00:00
Future < bool > canReplaceByFee ( String hash ) async {
final verboseTransaction = await electrumClient . getTransactionRaw ( hash: hash ) ;
final confirmations = verboseTransaction [ ' confirmations ' ] as int ? ? ? 0 ;
final transactionHex = verboseTransaction [ ' hex ' ] as String ? ;
if ( confirmations > 0 ) return false ;
if ( transactionHex = = null ) {
return false ;
}
final original = bitcoin . Transaction . fromHex ( transactionHex ) ;
return original . ins
. any ( ( element ) = > element . sequence ! = null & & element . sequence ! < 4294967293 ) ;
}
Future < bool > isChangeSufficientForFee ( String txId , int newFee ) async {
final bundle = await getTransactionExpanded ( hash: txId ) ;
final outputs = bundle . originalTransaction . outputs ;
final changeAddresses = walletAddresses . allAddresses . where ( ( element ) = > element . isHidden ) ;
// look for a change address in the outputs
final changeOutput = outputs . firstWhereOrNull ( ( output ) = > changeAddresses . any (
( element ) = > element . address = = addressFromOutputScript ( output . scriptPubKey , network ) ) ) ;
var allInputsAmount = 0 ;
for ( int i = 0 ; i < bundle . originalTransaction . inputs . length ; i + + ) {
final input = bundle . originalTransaction . inputs [ i ] ;
final inputTransaction = bundle . ins [ i ] ;
final vout = input . txIndex ;
final outTransaction = inputTransaction . outputs [ vout ] ;
allInputsAmount + = outTransaction . amount . toInt ( ) ;
}
int totalOutAmount = bundle . originalTransaction . outputs
. fold < int > ( 0 , ( previousValue , element ) = > previousValue + element . amount . toInt ( ) ) ;
var currentFee = allInputsAmount - totalOutAmount ;
int remainingFee = ( newFee - currentFee > 0 ) ? newFee - currentFee : newFee ;
return changeOutput ! = null & & changeOutput . amount . toInt ( ) - remainingFee > = 0 ;
}
Future < PendingBitcoinTransaction > replaceByFee ( String hash , int newFee ) async {
try {
final bundle = await getTransactionExpanded ( hash: hash ) ;
final utxos = < UtxoWithAddress > [ ] ;
List < ECPrivate > privateKeys = [ ] ;
var allInputsAmount = 0 ;
// Add inputs
for ( var i = 0 ; i < bundle . originalTransaction . inputs . length ; i + + ) {
final input = bundle . originalTransaction . inputs [ i ] ;
final inputTransaction = bundle . ins [ i ] ;
final vout = input . txIndex ;
final outTransaction = inputTransaction . outputs [ vout ] ;
final address = addressFromOutputScript ( outTransaction . scriptPubKey , network ) ;
allInputsAmount + = outTransaction . amount . toInt ( ) ;
final addressRecord =
walletAddresses . allAddresses . firstWhere ( ( element ) = > element . address = = address ) ;
final btcAddress = addressTypeFromStr ( addressRecord . address , network ) ;
final privkey = generateECPrivate (
hd: addressRecord . isHidden ? walletAddresses . sideHd : walletAddresses . mainHd ,
index: addressRecord . index ,
network: network ) ;
privateKeys . add ( privkey ) ;
utxos . add (
UtxoWithAddress (
utxo: BitcoinUtxo (
txHash: input . txId ,
value: outTransaction . amount ,
vout: vout ,
scriptType: _getScriptType ( btcAddress ) ,
) ,
ownerDetails:
UtxoAddressDetails ( publicKey: privkey . getPublic ( ) . toHex ( ) , address: btcAddress ) ,
) ,
) ;
}
int totalOutAmount = bundle . originalTransaction . outputs
. fold < int > ( 0 , ( previousValue , element ) = > previousValue + element . amount . toInt ( ) ) ;
var currentFee = allInputsAmount - totalOutAmount ;
int remainingFee = newFee - currentFee ;
final outputs = < BitcoinOutput > [ ] ;
// Add outputs and deduct the fees from it
for ( int i = bundle . originalTransaction . outputs . length - 1 ; i > = 0 ; i - - ) {
final out = bundle . originalTransaction . outputs [ i ] ;
final address = addressFromOutputScript ( out . scriptPubKey , network ) ;
final btcAddress = addressTypeFromStr ( address , network ) ;
int newAmount ;
if ( out . amount . toInt ( ) > = remainingFee ) {
newAmount = out . amount . toInt ( ) - remainingFee ;
remainingFee = 0 ;
// if new amount of output is less than dust amount, then don't add this output as well
if ( newAmount < = _dustAmount ) {
continue ;
}
} else {
remainingFee - = out . amount . toInt ( ) ;
continue ;
}
outputs . add ( BitcoinOutput ( address: btcAddress , value: BigInt . from ( newAmount ) ) ) ;
}
final changeAddresses = walletAddresses . allAddresses . where ( ( element ) = > element . isHidden ) ;
// look for a change address in the outputs
final changeOutput = outputs . firstWhereOrNull ( ( output ) = >
changeAddresses . any ( ( element ) = > element . address = = output . address . toAddress ( network ) ) ) ;
// deduct the change amount from the output amount
if ( changeOutput ! = null ) {
totalOutAmount - = changeOutput . value . toInt ( ) ;
}
final txb = BitcoinTransactionBuilder (
utxos: utxos ,
outputs: outputs ,
fee: BigInt . from ( newFee ) ,
network: network ,
enableRBF: true ,
) ;
final transaction = txb . buildTransaction ( ( txDigest , utxo , publicKey , sighash ) {
final key =
privateKeys . firstWhereOrNull ( ( element ) = > element . getPublic ( ) . toHex ( ) = = publicKey ) ;
if ( key = = null ) {
throw Exception ( " Cannot find private key " ) ;
}
if ( utxo . utxo . isP2tr ( ) ) {
return key . signTapRoot ( txDigest , sighash: sighash ) ;
} else {
return key . signInput ( txDigest , sigHash: sighash ) ;
}
} ) ;
return PendingBitcoinTransaction (
transaction ,
type ,
electrumClient: electrumClient ,
amount: totalOutAmount ,
fee: newFee ,
network: network ,
hasChange: changeOutput ! = null ,
feeRate: newFee . toString ( ) ,
) . . addListener ( ( transaction ) async {
transactionHistory . addOne ( transaction ) ;
await updateBalance ( ) ;
} ) ;
} catch ( e ) {
throw e ;
}
}
Future < ElectrumTransactionBundle > getTransactionExpanded ( { required String hash } ) 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
String transactionHex ;
int ? time ;
int confirmations = 0 ;
if ( network = = BitcoinNetwork . testnet ) {
// Testnet public electrum server does not support verbose transaction fetching
transactionHex = await electrumClient . getTransactionHex ( hash: hash ) ;
final status = json . decode (
( await http . get ( Uri . parse ( " https://blockstream.info/testnet/api/tx/ $ hash /status " ) ) ) . body ) ;
time = status [ " block_time " ] as int ? ;
2024-03-11 12:46:20 +00:00
final height = status [ " block_height " ] as int ? ? ? 0 ;
confirmations =
height > 0 ? ( await electrumClient . getCurrentBlockChainTip ( ) ) ! - height + 1 : 0 ;
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
} else {
final verboseTransaction = await electrumClient . getTransactionRaw ( hash: hash ) ;
transactionHex = verboseTransaction [ ' hex ' ] as String ;
time = verboseTransaction [ ' time ' ] as int ? ;
confirmations = verboseTransaction [ ' confirmations ' ] as int ? ? ? 0 ;
}
2024-02-26 18:32:54 +00:00
final original = BtcTransaction . fromRaw ( transactionHex ) ;
final ins = < BtcTransaction > [ ] ;
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
for ( final vin in original . inputs ) {
2024-02-28 15:48:42 +00:00
ins . add ( BtcTransaction . fromRaw ( await electrumClient . getTransactionHex ( hash: vin . txId ) ) ) ;
2022-01-17 15:33:51 +00:00
}
2024-04-08 14:54:58 +00:00
return ElectrumTransactionBundle (
original ,
ins: ins ,
time: time ,
confirmations: confirmations ,
) ;
2022-01-17 15:33:51 +00:00
}
2022-10-17 20:55:41 +00:00
Future < ElectrumTransactionInfo ? > fetchTransactionInfo (
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
{ required String hash ,
required int height ,
required Set < String > myAddresses ,
bool ? retryOnFailure } ) async {
2023-10-12 22:50:16 +00:00
try {
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
return ElectrumTransactionInfo . fromElectrumBundle (
2024-04-08 14:54:58 +00:00
await getTransactionExpanded ( hash: hash ) , walletInfo . type , network ,
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
addresses: myAddresses , height: height ) ;
} catch ( e ) {
if ( e is FormatException & & retryOnFailure = = true ) {
await Future . delayed ( const Duration ( seconds: 2 ) ) ;
return fetchTransactionInfo ( hash: hash , height: height , myAddresses: myAddresses ) ;
}
2023-10-12 22:50:16 +00:00
return null ;
}
2021-12-24 12:52:08 +00:00
}
@ override
Future < Map < String , ElectrumTransactionInfo > > fetchTransactions ( ) async {
2024-01-23 05:15:24 +00:00
try {
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 Map < String , ElectrumTransactionInfo > historiesWithDetails = { } ;
final addressesSet = walletAddresses . allAddresses . map ( ( addr ) = > addr . address ) . toSet ( ) ;
2024-03-01 23:38:53 +00:00
currentChainTip ? ? = await electrumClient . getCurrentBlockChainTip ( ) ? ? 0 ;
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
await Future . wait ( ADDRESS_TYPES . map ( ( type ) {
final addressesByType = walletAddresses . allAddresses . where ( ( addr ) = > addr . type = = type ) ;
return Future . wait ( addressesByType . map ( ( addressRecord ) async {
2024-03-01 23:38:53 +00:00
final history = await _fetchAddressHistory ( addressRecord , addressesSet , currentChainTip ! ) ;
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
if ( history . isNotEmpty ) {
addressRecord . txCount = history . length ;
historiesWithDetails . addAll ( history ) ;
final matchedAddresses =
addressesByType . where ( ( addr ) = > addr . isHidden = = addressRecord . isHidden ) ;
final isLastUsedAddress =
history . isNotEmpty & & addressRecord . address = = matchedAddresses . last . address ;
if ( isLastUsedAddress ) {
await walletAddresses . discoverAddresses (
matchedAddresses . toList ( ) ,
addressRecord . isHidden ,
( address , addressesSet ) = >
2024-03-01 23:38:53 +00:00
_fetchAddressHistory ( address , addressesSet , currentChainTip ! )
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
. then ( ( history ) = > history . isNotEmpty ? address . address : null ) ,
type: type ) ;
}
2024-01-23 05:15:24 +00:00
}
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
} ) ) ;
} ) ) ;
2024-01-23 05:15:24 +00:00
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
return historiesWithDetails ;
} catch ( e ) {
print ( e . toString ( ) ) ;
return { } ;
}
}
2024-01-23 05:15:24 +00:00
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
Future < Map < String , ElectrumTransactionInfo > > _fetchAddressHistory (
BitcoinAddressRecord addressRecord , Set < String > addressesSet , int currentHeight ) async {
try {
final Map < String , ElectrumTransactionInfo > historiesWithDetails = { } ;
final history = await electrumClient
2024-02-27 22:51:53 +00:00
. getHistory ( addressRecord . scriptHash ? ? addressRecord . updateScriptHash ( network ) ) ;
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
if ( history . isNotEmpty ) {
addressRecord . setAsUsed ( ) ;
await Future . wait ( history . map ( ( transaction ) async {
final txid = transaction [ ' tx_hash ' ] as String ;
final height = transaction [ ' height ' ] as int ;
final storedTx = transactionHistory . transactions [ txid ] ;
if ( storedTx ! = null ) {
if ( height > 0 ) {
storedTx . height = height ;
// the tx's block itself is the first confirmation so add 1
storedTx . confirmations = currentHeight - height + 1 ;
storedTx . isPending = storedTx . confirmations = = 0 ;
}
historiesWithDetails [ txid ] = storedTx ;
} else {
final tx = await fetchTransactionInfo (
hash: txid , height: height , myAddresses: addressesSet , retryOnFailure: true ) ;
if ( tx ! = null ) {
historiesWithDetails [ txid ] = tx ;
// Got a new transaction fetched, add it to the transaction history
// instead of waiting all to finish, and next time it will be faster
transactionHistory . addOne ( tx ) ;
await transactionHistory . save ( ) ;
}
}
2024-01-23 05:15:24 +00:00
return Future . value ( null ) ;
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
} ) ) ;
}
2024-01-23 05:15:24 +00:00
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
return historiesWithDetails ;
2024-01-23 05:15:24 +00:00
} catch ( e ) {
print ( e . toString ( ) ) ;
return { } ;
}
2021-12-24 12:52:08 +00:00
}
Future < void > updateTransactions ( ) async {
try {
if ( _isTransactionUpdating ) {
2024-04-09 23:35:00 +00:00
_isTransactionUpdating = false ;
2021-12-24 12:52:08 +00:00
return ;
}
2024-04-10 21:05:36 +00:00
transactionHistory . transactions . values . forEach ( ( tx ) {
if ( tx . unspents ! = null & & currentChainTip ! = null ) {
tx . confirmations = currentChainTip ! - tx . height + 1 ;
}
} ) ;
2021-12-24 12:52:08 +00:00
_isTransactionUpdating = true ;
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
await fetchTransactions ( ) ;
2022-01-24 12:04:23 +00:00
walletAddresses . updateReceiveAddresses ( ) ;
2021-12-24 12:52:08 +00:00
_isTransactionUpdating = false ;
2022-10-17 20:55:41 +00:00
} catch ( e , stacktrace ) {
print ( stacktrace ) ;
2021-12-24 12:52:08 +00:00
print ( e ) ;
_isTransactionUpdating = false ;
}
}
2024-02-26 18:32:54 +00:00
void _subscribeForUpdates ( ) async {
2021-12-24 12:52:08 +00:00
scriptHashes . forEach ( ( sh ) async {
await _scripthashesUpdateSubject [ sh ] ? . close ( ) ;
_scripthashesUpdateSubject [ sh ] = electrumClient . scripthashUpdate ( sh ) ;
2022-01-17 15:33:51 +00:00
_scripthashesUpdateSubject [ sh ] ? . listen ( ( event ) async {
2021-12-24 12:52:08 +00:00
try {
await updateUnspent ( ) ;
2023-04-20 13:46:41 +00:00
await updateBalance ( ) ;
2021-12-24 12:52:08 +00:00
await updateTransactions ( ) ;
2023-06-16 01:14:01 +00:00
} catch ( e , s ) {
2021-12-24 12:52:08 +00:00
print ( e . toString ( ) ) ;
2023-06-16 01:14:01 +00:00
_onError ? . call ( FlutterErrorDetails (
exception: e ,
stack: s ,
library : this . runtimeType . toString ( ) ,
) ) ;
2021-12-24 12:52:08 +00:00
}
} ) ;
} ) ;
2024-02-26 18:32:54 +00:00
await _chainTipUpdateSubject ? . close ( ) ;
_chainTipUpdateSubject = electrumClient . chainTipUpdate ( ) ;
_chainTipUpdateSubject ? . listen ( ( _ ) async {
try {
final currentHeight = await electrumClient . getCurrentBlockChainTip ( ) ;
if ( currentHeight ! = null ) walletInfo . restoreHeight = currentHeight ;
2024-02-26 18:33:31 +00:00
_setListeners ( walletInfo . restoreHeight , chainTip: currentHeight ) ;
2024-02-26 18:32:54 +00:00
} catch ( e , s ) {
print ( e . toString ( ) ) ;
_onError ? . call ( FlutterErrorDetails (
exception: e ,
stack: s ,
library : this . runtimeType . toString ( ) ,
) ) ;
}
} ) ;
2021-12-24 12:52:08 +00:00
}
Future < ElectrumBalance > _fetchBalances ( ) 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 addresses = walletAddresses . allAddresses . toList ( ) ;
2022-01-18 16:27:33 +00:00
final balanceFutures = < Future < Map < String , dynamic > > > [ ] ;
for ( var i = 0 ; i < addresses . length ; i + + ) {
2023-11-15 23:12:23 +00:00
final addressRecord = addresses [ i ] ;
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 sh = scriptHash ( addressRecord . address , network: network ) ;
2022-01-18 16:27:33 +00:00
final balanceFuture = electrumClient . getBalance ( sh ) ;
balanceFutures . add ( balanceFuture ) ;
2023-04-20 13:46:41 +00:00
}
var totalFrozen = 0 ;
2024-02-26 18:32:54 +00:00
var totalConfirmed = 0 ;
var totalUnconfirmed = 0 ;
2024-04-01 21:07:49 +00:00
if ( hasSilentPaymentsScanning ) {
// Add values from unspent coins that are not fetched by the address list
// i.e. scanned silent payments
unspentCoinsInfo . values . forEach ( ( info ) {
unspentCoins . forEach ( ( element ) {
if ( element . hash = = info . hash & &
element . bitcoinAddressRecord . address = = info . address & &
element . value = = info . value ) {
if ( info . isFrozen ) totalFrozen + = element . value ;
if ( element . bitcoinAddressRecord is BitcoinSilentPaymentAddressRecord ) {
totalConfirmed + = element . value ;
}
2024-02-26 18:32:54 +00:00
}
2024-04-01 21:07:49 +00:00
} ) ;
2023-04-20 13:46:41 +00:00
} ) ;
2024-04-01 21:07:49 +00:00
}
2022-01-18 16:27:33 +00:00
final balances = await Future . wait ( balanceFutures ) ;
for ( var i = 0 ; i < balances . length ; i + + ) {
final addressRecord = addresses [ i ] ;
final balance = balances [ i ] ;
2022-10-12 17:09:57 +00:00
final confirmed = balance [ ' confirmed ' ] as int ? ? ? 0 ;
final unconfirmed = balance [ ' unconfirmed ' ] as int ? ? ? 0 ;
2022-01-18 16:27:33 +00:00
totalConfirmed + = confirmed ;
totalUnconfirmed + = unconfirmed ;
if ( confirmed > 0 | | unconfirmed > 0 ) {
addressRecord . setAsUsed ( ) ;
}
}
2023-10-12 22:50:16 +00:00
return ElectrumBalance (
confirmed: totalConfirmed , unconfirmed: totalUnconfirmed , frozen: totalFrozen ) ;
2021-12-24 12:52:08 +00:00
}
2023-04-20 13:46:41 +00:00
Future < void > updateBalance ( ) async {
2022-03-30 15:57:04 +00:00
balance [ currency ] = await _fetchBalances ( ) ;
2021-12-24 12:52:08 +00:00
await save ( ) ;
}
2022-01-12 13:20:43 +00:00
String getChangeAddress ( ) {
const minCountOfHiddenAddresses = 5 ;
final random = Random ( ) ;
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
var addresses = walletAddresses . allAddresses . where ( ( addr ) = > addr . isHidden ) . toList ( ) ;
2022-01-12 13:20:43 +00:00
if ( addresses . length < minCountOfHiddenAddresses ) {
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
addresses = walletAddresses . allAddresses . toList ( ) ;
2022-01-12 13:20:43 +00:00
}
return addresses [ random . nextInt ( addresses . length ) ] . address ;
}
2023-06-16 01:14:01 +00:00
@ override
void setExceptionHandler ( void Function ( FlutterErrorDetails ) onError ) = > _onError = onError ;
2023-09-14 19:14:49 +00:00
@ override
String signMessage ( String message , { String ? address = null } ) {
final index = address ! = null
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
? walletAddresses . allAddresses . firstWhere ( ( element ) = > element . address = = address ) . index
2023-09-14 19:14:49 +00:00
: null ;
2023-12-08 14:05:52 +00:00
final HD = index = = null ? hd : hd . derive ( index ) ;
return base64Encode ( HD . signMessage ( message ) ) ;
2023-09-14 19:14:49 +00:00
}
2024-02-26 18:32:54 +00:00
Future < void > _setInitialHeight ( ) async {
2024-03-01 23:38:53 +00:00
currentChainTip = await electrumClient . getCurrentBlockChainTip ( ) ;
2024-04-01 22:19:31 +00:00
if ( currentChainTip ! = null & & walletInfo . restoreHeight = = 0 ) {
walletInfo . restoreHeight = currentChainTip ! ;
}
2024-02-26 18:32:54 +00:00
}
2024-04-01 21:07:49 +00:00
2024-03-21 02:51:57 +00:00
static BasedUtxoNetwork _getNetwork ( bitcoin . NetworkType networkType , CryptoCurrency ? currency ) {
if ( networkType = = bitcoin . bitcoin & & currency = = CryptoCurrency . bch ) {
return BitcoinCashNetwork . mainnet ;
}
if ( networkType = = litecoinNetwork ) {
return LitecoinNetwork . mainnet ;
}
if ( networkType = = bitcoin . testnet ) {
return BitcoinNetwork . testnet ;
}
return BitcoinNetwork . mainnet ;
}
2024-02-26 18:32:54 +00:00
}
2024-04-05 22:20:18 +00:00
class ScanNode {
final Uri uri ;
final bool ? useSSL ;
ScanNode ( this . uri , this . useSSL ) ;
}
2024-02-26 18:32:54 +00:00
class ScanData {
final SendPort sendPort ;
2024-03-01 23:38:53 +00:00
final SilentPaymentOwner silentAddress ;
2024-02-26 18:32:54 +00:00
final int height ;
2024-04-05 22:20:18 +00:00
final ScanNode node ;
2024-02-26 18:33:31 +00:00
final BasedUtxoNetwork network ;
2024-02-26 18:32:54 +00:00
final int chainTip ;
final ElectrumClient electrumClient ;
final List < String > transactionHistoryIds ;
final Map < String , String > labels ;
2024-04-09 15:15:21 +00:00
final bool isSingleScan ;
2024-02-26 18:32:54 +00:00
ScanData ( {
required this . sendPort ,
2024-03-01 23:38:53 +00:00
required this . silentAddress ,
2024-02-26 18:32:54 +00:00
required this . height ,
required this . node ,
2024-02-26 18:33:31 +00:00
required this . network ,
2024-02-26 18:32:54 +00:00
required this . chainTip ,
required this . electrumClient ,
required this . transactionHistoryIds ,
required this . labels ,
2024-04-09 15:15:21 +00:00
required this . isSingleScan ,
2024-02-26 18:32:54 +00:00
} ) ;
factory ScanData . fromHeight ( ScanData scanData , int newHeight ) {
return ScanData (
sendPort: scanData . sendPort ,
2024-03-01 23:38:53 +00:00
silentAddress: scanData . silentAddress ,
2024-02-26 18:32:54 +00:00
height: newHeight ,
node: scanData . node ,
2024-02-26 18:33:31 +00:00
network: scanData . network ,
2024-02-26 18:32:54 +00:00
chainTip: scanData . chainTip ,
transactionHistoryIds: scanData . transactionHistoryIds ,
electrumClient: scanData . electrumClient ,
labels: scanData . labels ,
2024-04-09 15:15:21 +00:00
isSingleScan: scanData . isSingleScan ,
2024-02-26 18:32:54 +00:00
) ;
}
}
class SyncResponse {
final int height ;
final SyncStatus syncStatus ;
SyncResponse ( this . height , this . syncStatus ) ;
}
2024-02-26 18:33:31 +00:00
Future < void > startRefresh ( ScanData scanData ) async {
var cachedBlockchainHeight = scanData . chainTip ;
2024-03-01 23:38:53 +00:00
Future < ElectrumClient > getElectrumConnection ( ) async {
2024-02-27 22:51:53 +00:00
final electrumClient = scanData . electrumClient ;
if ( ! electrumClient . isConnected ) {
final node = scanData . node ;
2024-04-05 20:27:42 +00:00
await electrumClient . connectToUri ( node . uri , useSSL: node . useSSL ) ;
2024-02-27 22:51:53 +00:00
}
return electrumClient ;
}
2024-04-10 21:05:36 +00:00
Future < int > getUpdatedNodeHeight ( ) async {
final electrumClient = await getElectrumConnection ( ) ;
return await electrumClient . getCurrentBlockChainTip ( ) ? ? cachedBlockchainHeight ;
2024-02-26 18:33:31 +00:00
}
var lastKnownBlockHeight = 0 ;
var initialSyncHeight = 0 ;
var syncHeight = scanData . height ;
var currentChainTip = scanData . chainTip ;
if ( syncHeight < = 0 ) {
syncHeight = currentChainTip ;
}
if ( initialSyncHeight < = 0 ) {
initialSyncHeight = syncHeight ;
}
if ( lastKnownBlockHeight = = syncHeight ) {
scanData . sendPort . send ( SyncResponse ( currentChainTip , SyncedSyncStatus ( ) ) ) ;
return ;
}
// Run this until no more blocks left to scan txs. At first this was recursive
// i.e. re-calling the startRefresh function but this was easier for the above values to retain
// their initial values
while ( true ) {
lastKnownBlockHeight = syncHeight ;
2024-04-09 15:15:21 +00:00
SyncingSyncStatus syncingStatus ;
if ( scanData . isSingleScan ) {
syncingStatus = SyncingSyncStatus ( 1 , 0 ) ;
} else {
2024-04-10 21:05:36 +00:00
syncingStatus = SyncingSyncStatus . fromHeightValues (
await getUpdatedNodeHeight ( ) , initialSyncHeight , syncHeight ) ;
2024-04-09 15:15:21 +00:00
}
2024-02-26 18:33:31 +00:00
scanData . sendPort . send ( SyncResponse ( syncHeight , syncingStatus ) ) ;
2024-04-09 15:15:21 +00:00
if ( syncingStatus . blocksLeft < = 0 | | ( scanData . isSingleScan & & scanData . height ! = syncHeight ) ) {
2024-04-10 21:05:36 +00:00
scanData . sendPort . send ( SyncResponse ( await getUpdatedNodeHeight ( ) , SyncedSyncStatus ( ) ) ) ;
2024-02-26 18:33:31 +00:00
return ;
}
try {
2024-03-01 23:38:53 +00:00
final electrumClient = await getElectrumConnection ( ) ;
2024-02-27 14:40:56 +00:00
2024-04-09 15:15:21 +00:00
final scanningBlockCount =
2024-04-09 23:35:00 +00:00
scanData . isSingleScan ? 1 : ( scanData . network = = BitcoinNetwork . testnet ? 50 : 10 ) ;
2024-04-05 20:27:42 +00:00
2024-03-11 12:46:20 +00:00
Map < String , dynamic > ? tweaks ;
2024-02-27 14:40:56 +00:00
try {
2024-04-05 20:27:42 +00:00
tweaks = await electrumClient . getTweaks ( height: syncHeight , count: scanningBlockCount ) ;
2024-02-27 14:40:56 +00:00
} catch ( e ) {
if ( e is RequestFailedTimeoutException ) {
2024-04-05 20:27:42 +00:00
return scanData . sendPort . send (
SyncResponse ( syncHeight , TimedOutSyncStatus ( ) ) ,
) ;
2024-02-27 14:40:56 +00:00
}
}
if ( tweaks = = null ) {
2024-04-05 20:27:42 +00:00
return scanData . sendPort . send (
SyncResponse ( syncHeight , UnsupportedSyncStatus ( ) ) ,
) ;
}
if ( tweaks . isEmpty ) {
syncHeight + = scanningBlockCount ;
continue ;
2024-02-27 14:40:56 +00:00
}
2024-02-26 18:33:31 +00:00
2024-04-05 20:27:42 +00:00
final blockHeights = tweaks . keys ;
2024-03-11 12:46:20 +00:00
for ( var i = 0 ; i < blockHeights . length ; i + + ) {
2024-02-26 18:33:31 +00:00
try {
2024-03-11 12:46:20 +00:00
final blockHeight = blockHeights . elementAt ( i ) . toString ( ) ;
final blockTweaks = tweaks [ blockHeight ] as Map < String , dynamic > ;
for ( var j = 0 ; j < blockTweaks . keys . length ; j + + ) {
final txid = blockTweaks . keys . elementAt ( j ) ;
final details = blockTweaks [ txid ] as Map < String , dynamic > ;
final outputPubkeys = ( details [ " output_pubkeys " ] as Map < dynamic , dynamic > ) ;
final tweak = details [ " tweak " ] . toString ( ) ;
2024-04-05 20:27:42 +00:00
try {
final spb = SilentPaymentBuilder ( receiverTweak: tweak ) ;
final addToWallet = spb . scanOutputs (
scanData . silentAddress . b_scan ,
scanData . silentAddress . B_spend ,
outputPubkeys . values
2024-04-09 15:15:21 +00:00
. map ( ( o ) = > getScriptFromOutput ( o [ 0 ] . toString ( ) , int . parse ( o [ 1 ] . toString ( ) ) ) )
2024-04-05 20:27:42 +00:00
. toList ( ) ,
precomputedLabels: scanData . labels ,
2024-03-11 12:46:20 +00:00
) ;
2024-02-27 14:40:56 +00:00
2024-04-05 20:27:42 +00:00
if ( addToWallet . isEmpty ) {
// no results tx, continue to next tx
continue ;
}
2024-02-26 18:33:31 +00:00
2024-04-05 20:27:42 +00:00
addToWallet . forEach ( ( key , value ) async {
final t_k = value . tweak ;
final addressRecord = BitcoinSilentPaymentAddressRecord (
value . output . address . toAddress ( scanData . network ) ,
index: 0 ,
isHidden: false ,
isUsed: true ,
network: scanData . network ,
silentPaymentTweak: t_k ,
type: SegwitAddresType . p2tr ,
) ;
int ? amount ;
int ? pos ;
outputPubkeys . entries . firstWhere ( ( k ) {
2024-04-09 15:15:21 +00:00
final matches = k . value [ 0 ] = = key ;
2024-04-05 20:27:42 +00:00
if ( matches ) {
2024-04-09 15:15:21 +00:00
amount = int . parse ( k . value [ 1 ] . toString ( ) ) ;
2024-04-05 20:27:42 +00:00
pos = int . parse ( k . key . toString ( ) ) ;
return true ;
}
return false ;
} ) ;
final json = < String , dynamic > {
' address_record ' : addressRecord . toJSON ( ) ,
' tx_hash ' : txid ,
' value ' : amount ! ,
' tx_pos ' : pos ! ,
' silent_payment_tweak ' : t_k ,
} ;
final tx = BitcoinUnspent . fromJSON ( addressRecord , json ) ;
final txInfo = ElectrumTransactionInfo (
WalletType . bitcoin ,
id: tx . hash ,
height: syncHeight ,
2024-04-10 21:05:36 +00:00
amount: amount ! ,
2024-04-05 20:27:42 +00:00
fee: 0 ,
direction: TransactionDirection . incoming ,
isPending: false ,
date: DateTime . now ( ) ,
2024-04-10 21:05:36 +00:00
confirmations: await getUpdatedNodeHeight ( ) - int . parse ( blockHeight ) + 1 ,
2024-04-05 20:27:42 +00:00
to: value . label ! = null
? SilentPaymentAddress (
version: scanData . silentAddress . version ,
B_scan: scanData . silentAddress . B_scan . tweakAdd (
BigintUtils . fromBytes ( BytesUtils . fromHexString ( value . tweak ) ) ) ,
B_spend: scanData . silentAddress . B_spend ,
hrp: scanData . silentAddress . hrp ,
) . toString ( )
: scanData . silentAddress . toString ( ) ,
unspents: [ tx ] ,
) ;
scanData . sendPort . send ( { txInfo . id: txInfo } ) ;
} ) ;
} catch ( _ ) { }
2024-03-11 12:46:20 +00:00
}
} catch ( e , s ) {
print ( [ e , s ] ) ;
}
2024-02-27 14:40:56 +00:00
2024-03-11 12:46:20 +00:00
// Finished scanning block, add 1 to height and continue to next block in loop
syncHeight + = 1 ;
scanData . sendPort . send ( SyncResponse ( syncHeight ,
SyncingSyncStatus . fromHeightValues ( currentChainTip , initialSyncHeight , syncHeight ) ) ) ;
2024-02-26 18:33:31 +00:00
}
} catch ( e , stacktrace ) {
print ( stacktrace ) ;
print ( e . toString ( ) ) ;
scanData . sendPort . send ( SyncResponse ( syncHeight , NotConnectedSyncStatus ( ) ) ) ;
break ;
}
}
}
2024-02-26 18:32:54 +00:00
class EstimatedTxResult {
2024-03-28 12:41:11 +00:00
EstimatedTxResult ( {
required this . utxos ,
2024-04-01 21:07:49 +00:00
required this . inputPrivKeyInfos ,
2024-03-28 12:41:11 +00:00
required this . fee ,
required this . amount ,
2024-03-29 18:51:34 +00:00
required this . hasChange ,
required this . isSendAll ,
2024-03-28 12:41:11 +00:00
this . memo ,
2024-04-01 21:07:49 +00:00
required this . spendsSilentPayment ,
2024-04-10 21:05:36 +00:00
required this . spendsCPFP ,
2024-03-28 12:41:11 +00:00
} ) ;
2024-02-26 18:32:54 +00:00
final List < UtxoWithAddress > utxos ;
2024-03-11 12:46:20 +00:00
final List < ECPrivateInfo > inputPrivKeyInfos ;
2024-02-26 18:32:54 +00:00
final int fee ;
final int amount ;
2024-03-05 14:54:40 +00:00
final bool spendsSilentPayment ;
2024-03-29 18:51:34 +00:00
final bool hasChange ;
final bool isSendAll ;
2024-03-28 12:41:11 +00:00
final String ? memo ;
2024-04-10 21:05:36 +00:00
final bool spendsCPFP ;
2024-02-26 18:32:54 +00:00
}
2024-03-21 02:51:57 +00:00
BitcoinBaseAddress addressTypeFromStr ( String address , BasedUtxoNetwork network ) {
2024-03-29 18:51:34 +00:00
if ( network is BitcoinCashNetwork ) {
if ( ! address . startsWith ( " bitcoincash: " ) & &
( address . startsWith ( " q " ) | | address . startsWith ( " p " ) ) ) {
address = " bitcoincash: $ address " ;
}
return BitcoinCashAddress ( address ) . baseAddress ;
}
2024-02-26 18:32:54 +00:00
if ( P2pkhAddress . regex . hasMatch ( address ) ) {
return P2pkhAddress . fromAddress ( address: address , network: network ) ;
} else if ( P2shAddress . regex . hasMatch ( address ) ) {
return P2shAddress . fromAddress ( address: address , network: network ) ;
} else if ( P2wshAddress . regex . hasMatch ( address ) ) {
return P2wshAddress . fromAddress ( address: address , network: network ) ;
} else if ( P2trAddress . regex . hasMatch ( address ) ) {
return P2trAddress . fromAddress ( address: address , network: network ) ;
2024-02-27 14:40:56 +00:00
} else if ( SilentPaymentAddress . regex . hasMatch ( address ) ) {
return SilentPaymentAddress . fromAddress ( address ) ;
2024-02-26 18:32:54 +00:00
} else {
return P2wpkhAddress . fromAddress ( address: address , network: network ) ;
}
}
BitcoinAddressType _getScriptType ( BitcoinBaseAddress type ) {
if ( type is P2pkhAddress ) {
return P2pkhAddressType . p2pkh ;
} else if ( type is P2shAddress ) {
return P2shAddressType . p2wpkhInP2sh ;
} else if ( type is P2wshAddress ) {
return SegwitAddresType . p2wsh ;
} else if ( type is P2trAddress ) {
return SegwitAddresType . p2tr ;
2024-02-27 14:40:56 +00:00
} else if ( type is SilentPaymentsAddresType ) {
return SilentPaymentsAddresType . p2sp ;
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
} else {
return SegwitAddresType . p2wpkh ;
}
}