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 ' ;
2024-05-09 20:06:39 +00:00
import ' package:cw_core/get_height_by_date.dart ' ;
2023-11-15 23:12:23 +00:00
import ' package:flutter/foundation.dart ' ;
import ' package:hive/hive.dart ' ;
2024-05-05 01:44:50 +00:00
import ' package:http/http.dart ' as http ;
2023-11-15 23:12:23 +00:00
import ' package:mobx/mobx.dart ' ;
import ' package:rxdart/subjects.dart ' ;
2024-04-12 18:28:01 +00:00
import ' package:sp_scanner/sp_scanner.dart ' ;
2021-12-24 12:52:08 +00:00
part ' electrum_wallet.g.dart ' ;
class ElectrumWallet = ElectrumWalletBase with _ $ElectrumWallet ;
2024-04-18 11:57:16 +00:00
const int TWEAKS_COUNT = 25 ;
2023-10-12 22:50:16 +00:00
abstract class ElectrumWalletBase
extends WalletBase < ElectrumBalance , ElectrumTransactionHistory , ElectrumTransactionInfo >
with Store {
2024-05-10 22:23:05 +00:00
ElectrumWalletBase ( {
required String password ,
required WalletInfo walletInfo ,
required Box < UnspentCoinsInfo > unspentCoinsInfo ,
required this . networkType ,
String ? xpub ,
String ? mnemonic ,
Uint8List ? seedBytes ,
this . passphrase ,
List < BitcoinAddressRecord > ? initialAddresses ,
ElectrumClient ? electrumClient ,
ElectrumBalance ? initialBalance ,
CryptoCurrency ? currency ,
this . alwaysScan ,
} ) : accountHD =
2024-05-05 01:44:50 +00:00
getAccountHDWallet ( currency , networkType , seedBytes , xpub , walletInfo . derivationInfo ) ,
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 ,
2024-05-05 01:44:50 +00:00
this . _mnemonic = mnemonic ,
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 ) {
2024-05-10 22:23:05 +00:00
if ( syncStatus is ! AttemptingSyncStatus & & syncStatus is ! SyncedTipSyncStatus )
2024-04-17 19:35:11 +00:00
silentPaymentsScanningActive = syncStatus is SyncingSyncStatus ;
if ( syncStatus is NotConnectedSyncStatus ) {
// Needs to re-subscribe to all scripthashes when reconnected
_scripthashesUpdateSubject = { } ;
}
2024-05-10 22:23:05 +00:00
// Message is shown on the UI for 3 seconds, revert to synced
if ( syncStatus is SyncedTipSyncStatus ) {
Timer ( Duration ( seconds: 3 ) , ( ) {
if ( this . syncStatus is SyncedTipSyncStatus ) this . syncStatus = SyncedSyncStatus ( ) ;
} ) ;
}
2024-04-05 20:27:42 +00:00
} ) ;
2021-12-24 12:52:08 +00:00
}
2024-05-05 01:44:50 +00:00
static bitcoin . HDWallet getAccountHDWallet (
CryptoCurrency ? currency ,
bitcoin . NetworkType networkType ,
Uint8List ? seedBytes ,
String ? xpub ,
DerivationInfo ? derivationInfo ) {
if ( seedBytes = = null & & xpub = = null ) {
throw Exception (
" To create a Wallet you need either a seed or an xpub. This should not happen " ) ;
}
if ( seedBytes ! = null ) {
return currency = = CryptoCurrency . bch
? bitcoinCashHDWallet ( seedBytes )
: bitcoin . HDWallet . fromSeed ( seedBytes , network: networkType )
. derivePath ( _hardenedDerivationPath ( derivationInfo ? . derivationPath ? ? " m/0' " ) ) ;
}
return bitcoin . HDWallet . fromBase58 ( xpub ! ) ;
}
2023-10-12 22:50:16 +00:00
static bitcoin . HDWallet bitcoinCashHDWallet ( Uint8List seedBytes ) = >
2024-05-05 01:44:50 +00:00
bitcoin . HDWallet . fromSeed ( seedBytes ) . derivePath ( " m/44'/145'/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
2024-05-10 22:23:05 +00:00
bool ? alwaysScan ;
2024-05-05 01:44:50 +00:00
final bitcoin . HDWallet accountHD ;
final String ? _mnemonic ;
bitcoin . HDWallet get hd = > accountHD . derive ( 0 ) ;
Bitcoin derivations (#1089)
* - Update and Fix Conflicts with main
* Add Balances for ERC20 tokens
* Fix conflicts with main
* Add erc20 abi json
* Add send erc20 tokens initial function
* add missing getHeightByDate in Haven [skip ci]
* Allow contacts and wallets from the same tag
* Add Shiba Inu icon
* Add send ERC-20 tokens initial flow
* Add missing import in generated file
* Add initial approach for transaction sending for ERC-20 tokens
* Refactor signing/sending transactions
* Add initial flow for transactions subscription
* Refactor signing/sending transactions
* Add home settings icon
* Fix conflicts with main
* Initial flow for home settings
* Add logic flow for adding erc20 tokens
* Fix initial UI
* Finalize UI for Tokens
* Integrate UI with Ethereum flow
* Add "Enable/Disable" feature for ERC20 tokens
* Add initial Erc20 tokens
* Add Sorting and Pin Native Token features
* Fix price sorting
* Sort tokens list as well when Sort criteria changes
* - Improve sorting balances flow
- Add initial add token from search bar flow
* Fix Accounts Popup UI
* Fix Pin native token
* Fix Enabling/Disabling tokens
Fix sorting by fiat once app is opened
Improve token availability mechanism
* Fix deleting token
Fix renaming tokens
* Fix issue with search
* Add more tokens
* - Fix scroll issue
- Add ERC20 tokens placeholder image in picker
* - Separate and organize default erc20 tokens
- Fix scrolling
- Add token placeholder images in picker
- Sort disabled tokens alphabetically
* Change BNB token initial availability [skip ci]
* Fix Conflicts with main
* Fix Conflicts with main
* Add Verse ERC20 token to the initial tokens list
* Add rename wallet to Ethereum
* Integrate EtherScan API for fetching address transactions
Generate Ethereum specific secrets in Ethereum package
* Adjust transactions fiat price for ERC20 tokens
* Free Up GitHub Actions Ubuntu Runner Disk Space
* Free Up GitHub Actions Ubuntu Runner Disk space (trial 2)
* Fix Transaction Fee display
* Save transaction history
* Enhance loading time for erc20 tokens transactions
* Minor Fixes and Enhancements
* Fix sending erc20
fix block explorer issue
* Fix int overflow
* Fix transaction amount conversions
* Minor: `slow` -> `Slow` [skip-ci]
* initial changes
* more base config stuff
* config changes
* successfully builds!
* save
* successfully add nano wallet
* save
* seed generation
* receive screen + node screen working
* tx history working and fiat fixes
* balance working
* derivation updates
* nano-unfinished
* sends working
* remove fees from send screen, send and receive transactions working
* fixes + auto receive incoming txs
* fix for scanning QR codes
* save
* update translations
* fixes
* more fixes
* more strings
* small fix
* fix github actions workflow
* potential fix
* potential fix
* ci/cd fix
* change rep working
* seed generation fixes
* fixes
* save
* change rep screen functional
* save
* banano changes
* fixes, start adding ui for PoW
* pow node changes
* update translations
* fix
* account changing barely working
* save
* disable account generation
* small fix
* save
* UI work
* save
* fixes after merge main
* fixes
* remove monero stuff, work on derivation ui
* lots of fixes + finish up seed derivation
* last minute fixes
* node related fixes
* more fixes
* small fix
* more fixes
* fixes
* pretty big refactor for pow, still some bugs
* finally works!
* get transactions after send
* fix
* merge conflict fixes
* save
* fix pow node showing up twice
* done
* initial changes
* small fix
* more merge fixes
* fixes
* more fixes
* fix
* save
* fix manage pow nodes setting appearing on other wallets
* fix contact bug
* fixes
* fiat fixes
* save
* save
* save
* save
* updates
* cleanup
* restore fix
* fixes
* remove deprecated alert
* fix
* small fix
* remove outdated warning
* electrum restore fixes
* fixes
* fixes
* fix
* derivation fixes
* nano fixes pt.1
* nano fixes pt.2
* bip39 fixes
* pownode refactor
* nodes pages fixes
* observer fix
* ssl fix
* remove old references
* remove unused imports
* code cleanup
* small fix
* small potential fix
* save
* derivation fixes
* deterministic fix
* fix pt.2
* derivation class fixes
* review fixes from nano that also apply here
* formatting
* stuff that should've stayed deleted
* post merge fixes
* remove problematic imports and duplicate changes
* Delete lib/nano/nano.dart
* move wallet restore page proxy code to the view model
* fix dashboard page indicators being the same color
* debatably better refactoring of derivationInfo, migration needed
* additional refactor improvements
* blanket comment some stuff out to narrow down this issue
* refactor fixes
* fix nano exchange
* fix , bug, i.e. replace , with . when making a nano transaction
* fix nano sending, update restore page wording, and other minor fixes
* write migration for existing bitcoin and nano wallets
* merge fixes
* minor fixes
* use default derivation type when restoring from qr code
* fixes for restoring
* fixes
* fixes
* merge fix
* Fix issues with Creating Electrum and Restoring Bip39
* updates & fixes
* Add missing case for no transactions BIP39 wallet restore
* Make the default BIP39 the 84 derivation path
* Add Samourai Deposit
* litecoin mnemonic error fix
* Bip39 passphrase support (#1412)
* save
* passphrase working
* fix for when loading wallets + translation update
* minor fix
* Fix Nano
* minor fix [skip ci]
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
* change error state seed conditions into throwables [skip ci]
* litecoin fixes
* Bip39 minor enhancements (#1416)
* minor enhancements
* rename bitcoin_derivations -> electrum_derivations
* Remove duplicate derivations
handle default case
* minor fix
* Enable passphrase for Litecoin
* obscure text of passphrase
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com>
Co-authored-by: fossephate <fosse@book.local>
2024-04-30 00:49:56 +00:00
final String ? passphrase ;
2021-12-24 12:52:08 +00:00
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-04-17 19:35:11 +00:00
Set < String > get addressesSet = > walletAddresses . allAddresses . map ( ( addr ) = > addr . address ) . toSet ( ) ;
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
List < String > get scriptHashes = > walletAddresses . addressesByReceiveType
. 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
2024-05-05 01:44:50 +00:00
String get xpub = > accountHD . base58 ! ;
2021-12-24 12:52:08 +00:00
@ override
2024-05-05 01:44:50 +00:00
String ? get seed = > _mnemonic ;
2021-12-24 12:52:08 +00:00
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-04-17 19:35:11 +00:00
bool get hasSilentPaymentsScanning = > type = = WalletType . bitcoin ;
2024-02-27 14:40:56 +00:00
@ observable
bool nodeSupportsSilentPayments = true ;
2024-04-01 22:19:31 +00:00
@ observable
bool silentPaymentsScanningActive = false ;
@ action
2024-04-12 21:31:23 +00:00
Future < void > setSilentPaymentsScanning ( bool active ) async {
2024-04-17 19:35:11 +00:00
syncStatus = AttemptingSyncStatus ( ) ;
2024-04-05 20:27:42 +00:00
silentPaymentsScanningActive = active ;
2024-04-01 22:19:31 +00:00
2024-04-05 20:27:42 +00:00
if ( active ) {
2024-05-10 22:23:05 +00:00
final tip = await getCurrentChainTip ( ) ;
if ( tip = = walletInfo . restoreHeight ) {
syncStatus = SyncedTipSyncStatus ( tip ) ;
}
if ( tip > walletInfo . restoreHeight ) {
2024-04-17 19:35:11 +00:00
_setListeners ( walletInfo . restoreHeight , chainTipParam: _currentChainTip ) ;
2024-04-12 21:31:23 +00:00
}
2024-04-01 22:19:31 +00:00
} else {
2024-05-11 13:14:14 +00:00
alwaysScan = false ;
2024-04-01 22:19:31 +00:00
_isolate ? . then ( ( runningIsolate ) = > runningIsolate . kill ( priority: Isolate . immediate ) ) ;
if ( electrumClient . isConnected ) {
syncStatus = SyncedSyncStatus ( ) ;
} else {
if ( electrumClient . uri ! = null ) {
2024-04-12 21:31:23 +00:00
await electrumClient . connectToUri ( electrumClient . uri ! ) ;
startSync ( ) ;
2024-04-01 22:19:31 +00:00
}
}
}
}
2024-02-27 14:40:56 +00:00
2024-02-27 22:51:53 +00:00
@ observable
2024-04-17 19:35:11 +00:00
int ? _currentChainTip ;
2024-04-18 00:26:42 +00:00
Future < int > getCurrentChainTip ( ) async {
return _currentChainTip ? ? await electrumClient . getCurrentBlockChainTip ( ) ? ? 0 ;
}
2024-02-27 22:51:53 +00:00
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 ;
2024-04-17 19:35:11 +00:00
// ignore: prefer_final_fields
2022-10-12 17:09:57 +00:00
Map < String , BehaviorSubject < Object > ? > _scripthashesUpdateSubject ;
2024-04-17 19:35:11 +00:00
// ignore: prefer_final_fields
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-17 19:35:11 +00:00
Future < void > _setListeners ( int height , { int ? chainTipParam , bool ? doSingleScan } ) async {
2024-04-18 00:26:42 +00:00
final chainTip = chainTipParam ? ? await getCurrentChainTip ( ) ;
2024-05-10 22:23:05 +00:00
if ( chainTip = = height ) {
syncStatus = NotConnectedSyncStatus ( ) ;
return ;
}
2024-02-26 18:33:31 +00:00
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 ,
2024-04-17 19:35:11 +00:00
chainTip: chainTip ,
2024-02-26 18:33:31 +00:00
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-12 18:28:01 +00:00
labelIndexes: walletAddresses . silentAddresses
. where ( ( addr ) = > addr . type = = SilentPaymentsAddresType . p2sp & & addr . index > = 1 )
. map ( ( addr ) = > addr . index )
. toList ( ) ,
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 ) {
final existingTxInfo = transactionHistory . transactions [ txid ] ;
2024-04-12 21:31:23 +00:00
final txAlreadyExisted = existingTxInfo ! = null ;
2024-04-12 18:28:01 +00:00
2024-04-17 19:35:11 +00:00
void updateSilentAddressRecord ( BitcoinSilentPaymentsUnspent unspent ) {
final silentAddress = walletAddresses . silentAddress ! ;
final silentPaymentAddress = SilentPaymentAddress (
version: silentAddress . version ,
B_scan: silentAddress . B_scan ,
B_spend: unspent . silentPaymentLabel ! = null
? silentAddress . B_spend . tweakAdd (
BigintUtils . fromBytes (
BytesUtils . fromHexString ( unspent . silentPaymentLabel ! ) ) ,
)
: silentAddress . B_spend ,
hrp: silentAddress . hrp ,
) ;
final addressRecord = walletAddresses . silentAddresses . firstWhereOrNull (
( address ) = > address . address = = silentPaymentAddress . toString ( ) ) ;
addressRecord ? . txCount + = 1 ;
addressRecord ? . balance + = unspent . value ;
walletAddresses . addSilentAddresses (
[ unspent . bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord ] ,
) ;
}
2024-04-12 21:31:23 +00:00
// Updating tx after re-scanned
if ( txAlreadyExisted ) {
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 ) {
2024-04-17 19:35:11 +00:00
newUnspents . forEach ( updateSilentAddressRecord ) ;
2024-02-27 22:51:53 +00:00
existingTxInfo . unspents ? ? = [ ] ;
existingTxInfo . unspents ! . addAll ( newUnspents ) ;
2024-03-01 23:38:53 +00:00
2024-04-17 19:35:11 +00:00
final newAmount = 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 ) {
2024-04-17 19:35:11 +00:00
existingTxInfo . amount + = newAmount ;
2024-03-01 23:38:53 +00:00
}
2024-04-17 19:35:11 +00:00
// Updates existing TX
2024-03-01 23:38:53 +00:00
transactionHistory . addOne ( existingTxInfo ) ;
2024-04-17 19:35:11 +00:00
// Update balance record
balance [ currency ] ! . confirmed + = newAmount ;
2024-02-27 22:51:53 +00:00
}
} else {
2024-04-17 19:35:11 +00:00
// else: First time seeing this TX after scanning
tx . unspents ! . forEach ( updateSilentAddressRecord ) ;
2024-04-12 21:31:23 +00:00
2024-04-17 19:35:11 +00:00
// Add new TX record
2024-02-27 22:51:53 +00:00
transactionHistory . addMany ( message ) ;
2024-04-17 19:35:11 +00:00
// Update balance record
balance [ currency ] ! . confirmed + = tx . amount ;
2024-02-27 22:51:53 +00:00
}
2024-03-01 23:38:53 +00:00
2024-04-17 19:35:11 +00:00
await updateAllUnspents ( ) ;
2024-02-26 18:33:31 +00:00
}
}
}
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 ;
2024-05-09 20:06:39 +00:00
await walletInfo . updateRestoreHeight ( message . height ) ;
2024-02-26 18:33:31 +00:00
}
}
}
2024-02-26 18:32:54 +00:00
2021-12-24 12:52:08 +00:00
@ action
@ override
Future < void > startSync ( ) async {
try {
2024-04-17 19:35:11 +00:00
syncStatus = SyncronizingSyncStatus ( ) ;
2024-02-27 22:51:53 +00:00
2024-04-10 21:05:36 +00:00
if ( hasSilentPaymentsScanning ) {
2024-04-17 19:35:11 +00:00
await _setInitialHeight ( ) ;
2024-04-10 21:05:36 +00:00
}
2024-02-26 18:32:54 +00:00
2024-04-17 19:35:11 +00:00
await _subscribeForUpdates ( ) ;
2021-12-24 12:52:08 +00:00
await updateTransactions ( ) ;
2024-05-08 13:28:25 +00:00
await updateAllUnspents ( ) ;
await updateBalance ( ) ;
2021-12-24 12:52:08 +00:00
2024-05-08 13:28:25 +00:00
await updateFeeRates ( ) ;
2024-05-09 20:06:39 +00:00
2024-05-11 13:14:14 +00:00
if ( alwaysScan = = true ) {
_setListeners ( walletInfo . restoreHeight ) ;
} else {
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-17 19:35:11 +00:00
@ action
Future < void > updateFeeRates ( ) async {
final feeRates = await electrumClient . feeRates ( network: network ) ;
if ( feeRates ! = [ 0 , 0 , 0 ] ) {
_feeRates = feeRates ;
}
}
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
2024-04-17 19:35:11 +00:00
await electrumClient . close ( ) ;
2024-04-09 23:35:00 +00:00
2024-05-11 13:14:14 +00:00
electrumClient . onConnectionStatusChange = ( bool isConnected ) async {
if ( syncStatus is SyncingSyncStatus ) return ;
2024-04-18 00:26:42 +00:00
2024-05-11 13:14:14 +00:00
if ( isConnected & & syncStatus is ! SyncedSyncStatus ) {
syncStatus = ConnectedSyncStatus ( ) ;
} else if ( ! isConnected ) {
syncStatus = LostConnectionSyncStatus ( ) ;
}
} ;
2024-04-09 23:35:00 +00:00
2024-05-11 13:14:14 +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-18 13:38:18 +00:00
UtxoDetails _createUTXOS ( {
required bool sendAll ,
required int credentialsAmount ,
required bool paysToSilentPayment ,
int ? inputsCount ,
} ) {
List < UtxoWithAddress > utxos = [ ] ;
2024-02-27 14:40:56 +00:00
List < Outpoint > vinOutpoints = [ ] ;
List < ECPrivateInfo > inputPrivKeyInfos = [ ] ;
2024-05-05 01:44:50 +00:00
final publicKeys = < String , PublicKeyWithDerivationPath > { } ;
2024-04-18 13:38:18 +00:00
int allInputsAmount = 0 ;
2024-03-05 14:54:40 +00:00
bool spendsSilentPayment = false ;
2024-04-26 19:29:31 +00:00
bool spendsUnconfirmedTX = false ;
2024-02-27 14:40:56 +00:00
2024-04-18 13:38:18 +00:00
int leftAmount = credentialsAmount ;
final availableInputs = unspentCoins . where ( ( utx ) = > utx . isSending & & ! utx . isFrozen ) . toList ( ) ;
2024-05-06 13:19:03 +00:00
final unconfirmedCoins = availableInputs . where ( ( utx ) = > utx . confirmations = = 0 ) . toList ( ) ;
2021-12-24 12:52:08 +00:00
2024-04-18 13:38:18 +00:00
for ( int i = 0 ; i < availableInputs . length ; i + + ) {
final utx = availableInputs [ i ] ;
2024-05-06 13:19:03 +00:00
if ( ! spendsUnconfirmedTX ) spendsUnconfirmedTX = utx . confirmations = = 0 ;
2024-04-17 19:35:11 +00:00
2024-04-18 13:38:18 +00:00
if ( paysToSilentPayment ) {
// Check inputs for shared secret derivation
if ( utx . bitcoinAddressRecord . type = = SegwitAddresType . p2wsh ) {
throw BitcoinTransactionSilentPaymentsNotSupported ( ) ;
}
}
2024-04-10 21:05:36 +00:00
2024-04-18 13:38:18 +00:00
allInputsAmount + = utx . value ;
leftAmount = leftAmount - utx . value ;
2024-02-27 22:51:53 +00:00
2024-04-18 13:38:18 +00:00
final address = addressTypeFromStr ( utx . address , network ) ;
ECPrivate ? privkey ;
bool ? isSilentPayment = false ;
2024-04-01 21:07:49 +00:00
2024-05-06 15:14:58 +00:00
final hd =
utx . bitcoinAddressRecord . isHidden ? walletAddresses . sideHd : walletAddresses . mainHd ;
final derivationPath =
" ${ _hardenedDerivationPath ( walletInfo . derivationInfo ? . derivationPath ? ? " m/0' " ) } "
" / ${ utx . bitcoinAddressRecord . isHidden ? " 1 " : " 0 " } "
" / ${ utx . bitcoinAddressRecord . index } " ;
final pubKeyHex = hd . derive ( utx . bitcoinAddressRecord . index ) . pubKey ! ;
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-05-06 15:14:58 +00:00
publicKeys [ address . pubKeyHash ( ) ] = PublicKeyWithDerivationPath ( pubKeyHex , derivationPath ) ;
2024-04-18 13:38:18 +00:00
if ( utx . bitcoinAddressRecord is BitcoinSilentPaymentAddressRecord ) {
final unspentAddress = utx . bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord ;
privkey = walletAddresses . silentAddress ! . b_spend . tweakAdd (
BigintUtils . fromBytes (
BytesUtils . fromHexString ( unspentAddress . silentPaymentTweak ! ) ,
) ,
) ;
spendsSilentPayment = true ;
isSilentPayment = true ;
} else {
2024-05-06 15:14:58 +00:00
privkey =
generateECPrivate ( hd: hd , index: utx . bitcoinAddressRecord . index , network: network ) ;
2024-04-18 13:38:18 +00:00
}
2024-02-26 18:32:54 +00:00
2024-04-18 13:38:18 +00:00
vinOutpoints . add ( Outpoint ( txid: utx . hash , index: utx . vout ) ) ;
inputPrivKeyInfos . add ( ECPrivateInfo (
privkey ,
address . type = = SegwitAddresType . p2tr ,
tweak: ! isSilentPayment ,
) ) ;
2024-02-26 18:32:54 +00:00
2024-04-18 13:38:18 +00:00
utxos . add (
UtxoWithAddress (
utxo: BitcoinUtxo (
txHash: utx . hash ,
value: BigInt . from ( utx . value ) ,
vout: utx . vout ,
scriptType: _getScriptType ( address ) ,
isSilentPayment: isSilentPayment ,
2024-02-26 18:32:54 +00:00
) ,
2024-04-18 13:38:18 +00:00
ownerDetails: UtxoAddressDetails (
publicKey: privkey . getPublic ( ) . toHex ( ) ,
address: address ,
) ,
) ,
) ;
// sendAll continues for all inputs
if ( ! sendAll ) {
bool amountIsAcquired = leftAmount < = 0 ;
if ( ( inputsCount = = null & & amountIsAcquired ) | | inputsCount = = i + 1 ) {
break ;
}
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-18 13:38:18 +00:00
return UtxoDetails (
availableInputs: availableInputs ,
2024-05-06 13:19:03 +00:00
unconfirmedCoins: unconfirmedCoins ,
2024-04-18 13:38:18 +00:00
utxos: utxos ,
vinOutpoints: vinOutpoints ,
inputPrivKeyInfos: inputPrivKeyInfos ,
2024-05-06 15:14:58 +00:00
publicKeys: publicKeys ,
2024-04-18 13:38:18 +00:00
allInputsAmount: allInputsAmount ,
spendsSilentPayment: spendsSilentPayment ,
2024-05-06 13:19:03 +00:00
spendsUnconfirmedTX: spendsUnconfirmedTX ,
2024-04-18 13:38:18 +00:00
) ;
}
Future < EstimatedTxResult > estimateSendAllTx (
List < BitcoinOutput > outputs ,
int feeRate , {
String ? memo ,
int credentialsAmount = 0 ,
bool hasSilentPayment = false ,
} ) async {
final utxoDetails = _createUTXOS (
sendAll: true ,
credentialsAmount: credentialsAmount ,
paysToSilentPayment: hasSilentPayment ,
) ;
2024-04-05 20:27:42 +00:00
2024-03-29 18:51:34 +00:00
int estimatedSize ;
if ( network is BitcoinCashNetwork ) {
estimatedSize = ForkedTransactionBuilder . estimateTransactionSize (
2024-04-18 13:38:18 +00:00
utxos: utxoDetails . utxos ,
2024-03-29 18:51:34 +00:00
outputs: outputs ,
network: network as BitcoinCashNetwork ,
memo: memo ,
) ;
} else {
estimatedSize = BitcoinTransactionBuilder . estimateTransactionSize (
2024-04-18 13:38:18 +00:00
utxos: utxoDetails . utxos ,
2024-03-29 18:51:34 +00:00
outputs: outputs ,
network: network ,
memo: memo ,
2024-04-18 13:38:18 +00:00
inputPrivKeyInfos: utxoDetails . inputPrivKeyInfos ,
vinOutpoints: utxoDetails . vinOutpoints ,
2024-03-29 18:51:34 +00:00
) ;
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
2024-04-18 13:38:18 +00:00
int amount = utxoDetails . allInputsAmount - fee ;
2022-07-28 17:03:16 +00:00
2024-04-17 19:35:11 +00:00
if ( amount < = 0 ) {
2024-04-18 13:38:18 +00:00
throw BitcoinTransactionWrongBalanceException ( amount: utxoDetails . allInputsAmount + fee ) ;
2024-04-17 19:35:11 +00:00
}
2024-04-26 19:29:31 +00:00
if ( amount < = 0 ) {
throw BitcoinTransactionWrongBalanceException ( ) ;
}
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-04-30 15:50:58 +00:00
if ( outputs . length = = 1 ) {
outputs [ 0 ] = BitcoinOutput ( address: outputs . last . address , value: BigInt . from ( amount ) ) ;
}
2024-03-29 18:51:34 +00:00
return EstimatedTxResult (
2024-04-18 13:38:18 +00:00
utxos: utxoDetails . utxos ,
inputPrivKeyInfos: utxoDetails . inputPrivKeyInfos ,
2024-05-06 15:14:58 +00:00
publicKeys: utxoDetails . publicKeys ,
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-05-06 13:19:03 +00:00
spendsUnconfirmedTX: utxoDetails . spendsUnconfirmedTX ,
2024-05-08 13:28:25 +00:00
spendsSilentPayment: utxoDetails . spendsSilentPayment ,
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-26 19:29:31 +00:00
bool ? useUnconfirmed ,
2024-04-01 21:07:49 +00:00
bool hasSilentPayment = false ,
2024-03-29 18:51:34 +00:00
} ) async {
2024-04-18 13:38:18 +00:00
final utxoDetails = _createUTXOS (
sendAll: false ,
credentialsAmount: credentialsAmount ,
inputsCount: inputsCount ,
paysToSilentPayment: hasSilentPayment ,
) ;
2024-04-05 20:27:42 +00:00
2024-04-18 13:38:18 +00:00
final spendingAllCoins = utxoDetails . availableInputs . length = = utxoDetails . utxos . length ;
2024-05-06 13:19:03 +00:00
final spendingAllConfirmedCoins = ! utxoDetails . spendsUnconfirmedTX & &
utxoDetails . utxos . length = =
utxoDetails . availableInputs . length - utxoDetails . unconfirmedCoins . length ;
2024-03-29 18:51:34 +00:00
// How much is being spent - how much is being sent
2024-04-18 13:38:18 +00:00
int amountLeftForChangeAndFee = utxoDetails . allInputsAmount - credentialsAmount ;
2024-03-29 18:51:34 +00:00
if ( amountLeftForChangeAndFee < = 0 ) {
2024-04-17 19:35:11 +00:00
if ( ! spendingAllCoins ) {
return estimateTxForAmount (
credentialsAmount ,
outputs ,
feeRate ,
2024-04-18 13:38:18 +00:00
inputsCount: utxoDetails . utxos . length + 1 ,
2024-04-17 19:35:11 +00:00
memo: memo ,
hasSilentPayment: hasSilentPayment ,
) ;
}
2024-04-18 13:38:18 +00:00
2024-03-29 18:51:34 +00:00
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 (
2024-04-18 13:38:18 +00:00
utxos: utxoDetails . utxos ,
2024-03-29 18:51:34 +00:00
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 (
2024-04-18 13:38:18 +00:00
utxos: utxoDetails . utxos ,
2024-03-29 18:51:34 +00:00
outputs: outputs ,
network: network ,
memo: memo ,
2024-04-18 13:38:18 +00:00
inputPrivKeyInfos: utxoDetails . inputPrivKeyInfos ,
vinOutpoints: utxoDetails . vinOutpoints ,
2024-03-29 18:51:34 +00:00
) ;
}
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 ,
2024-04-18 13:38:18 +00:00
inputsCount: utxoDetails . utxos . length + 1 ,
2024-03-29 18:51:34 +00:00
memo: memo ,
2024-04-26 19:29:31 +00:00
useUnconfirmed: useUnconfirmed ? ? spendingAllConfirmedCoins ,
2024-03-29 18:51:34 +00:00
) ;
}
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-18 13:38:18 +00:00
final maxAmountWithReturningChange = utxoDetails . 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
}
2024-04-18 13:38:18 +00:00
if ( totalAmount > utxoDetails . 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-05-10 22:23:05 +00:00
outputs . removeLast ( ) ;
2024-03-29 18:51:34 +00:00
return estimateTxForAmount (
credentialsAmount ,
outputs ,
feeRate ,
2024-04-18 13:38:18 +00:00
inputsCount: utxoDetails . utxos . length + 1 ,
2024-03-29 18:51:34 +00:00
memo: memo ,
2024-04-26 19:29:31 +00:00
useUnconfirmed: useUnconfirmed ? ? spendingAllConfirmedCoins ,
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-04-18 13:38:18 +00:00
utxos: utxoDetails . utxos ,
inputPrivKeyInfos: utxoDetails . inputPrivKeyInfos ,
2024-05-06 15:14:58 +00:00
publicKeys: utxoDetails . publicKeys ,
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-05-06 13:19:03 +00:00
spendsUnconfirmedTX: utxoDetails . spendsUnconfirmedTX ,
2024-05-08 13:28:25 +00:00
spendsSilentPayment: utxoDetails . spendsSilentPayment ,
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-05-05 01:44:50 +00:00
if ( walletInfo . isHardwareWallet ) {
final transaction = await buildHardwareWalletTransaction (
utxos: estimatedTx . utxos ,
outputs: outputs ,
publicKeys: estimatedTx . publicKeys ,
fee: BigInt . from ( estimatedTx . fee ) ,
network: network ,
memo: estimatedTx . memo ,
outputOrdering: BitcoinOrdering . none ,
enableRBF: true ,
) ;
return PendingBitcoinTransaction (
transaction ,
type ,
electrumClient: electrumClient ,
amount: estimatedTx . amount ,
fee: estimatedTx . fee ,
feeRate: feeRateInt . toString ( ) ,
network: network ,
hasChange: estimatedTx . hasChange ,
isSendAll: estimatedTx . isSendAll ,
hasTaprootInputs: false , // ToDo: (Konsti) Support Taproot
) . . addListener ( ( transaction ) async {
transactionHistory . addOne ( transaction ) ;
await updateBalance ( ) ;
} ) ;
}
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-26 19:29:31 +00:00
enableRBF: ! estimatedTx . spendsUnconfirmedTX ,
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-26 19:29:31 +00:00
enableRBF: ! estimatedTx . spendsUnconfirmedTX ,
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
}
2024-05-05 01:44:50 +00:00
Future < BtcTransaction > buildHardwareWalletTransaction ( {
required List < BitcoinBaseOutput > outputs ,
required BigInt fee ,
required BasedUtxoNetwork network ,
required List < UtxoWithAddress > utxos ,
required Map < String , PublicKeyWithDerivationPath > publicKeys ,
String ? memo ,
bool enableRBF = false ,
BitcoinOrdering inputOrdering = BitcoinOrdering . bip69 ,
BitcoinOrdering outputOrdering = BitcoinOrdering . bip69 ,
} ) async = >
throw UnimplementedError ( ) ;
2021-12-24 12:52:08 +00:00
String toJSON ( ) = > json . encode ( {
2024-05-05 01:44:50 +00:00
' mnemonic ' : _mnemonic ,
' xpub ' : xpub ,
Bitcoin derivations (#1089)
* - Update and Fix Conflicts with main
* Add Balances for ERC20 tokens
* Fix conflicts with main
* Add erc20 abi json
* Add send erc20 tokens initial function
* add missing getHeightByDate in Haven [skip ci]
* Allow contacts and wallets from the same tag
* Add Shiba Inu icon
* Add send ERC-20 tokens initial flow
* Add missing import in generated file
* Add initial approach for transaction sending for ERC-20 tokens
* Refactor signing/sending transactions
* Add initial flow for transactions subscription
* Refactor signing/sending transactions
* Add home settings icon
* Fix conflicts with main
* Initial flow for home settings
* Add logic flow for adding erc20 tokens
* Fix initial UI
* Finalize UI for Tokens
* Integrate UI with Ethereum flow
* Add "Enable/Disable" feature for ERC20 tokens
* Add initial Erc20 tokens
* Add Sorting and Pin Native Token features
* Fix price sorting
* Sort tokens list as well when Sort criteria changes
* - Improve sorting balances flow
- Add initial add token from search bar flow
* Fix Accounts Popup UI
* Fix Pin native token
* Fix Enabling/Disabling tokens
Fix sorting by fiat once app is opened
Improve token availability mechanism
* Fix deleting token
Fix renaming tokens
* Fix issue with search
* Add more tokens
* - Fix scroll issue
- Add ERC20 tokens placeholder image in picker
* - Separate and organize default erc20 tokens
- Fix scrolling
- Add token placeholder images in picker
- Sort disabled tokens alphabetically
* Change BNB token initial availability [skip ci]
* Fix Conflicts with main
* Fix Conflicts with main
* Add Verse ERC20 token to the initial tokens list
* Add rename wallet to Ethereum
* Integrate EtherScan API for fetching address transactions
Generate Ethereum specific secrets in Ethereum package
* Adjust transactions fiat price for ERC20 tokens
* Free Up GitHub Actions Ubuntu Runner Disk Space
* Free Up GitHub Actions Ubuntu Runner Disk space (trial 2)
* Fix Transaction Fee display
* Save transaction history
* Enhance loading time for erc20 tokens transactions
* Minor Fixes and Enhancements
* Fix sending erc20
fix block explorer issue
* Fix int overflow
* Fix transaction amount conversions
* Minor: `slow` -> `Slow` [skip-ci]
* initial changes
* more base config stuff
* config changes
* successfully builds!
* save
* successfully add nano wallet
* save
* seed generation
* receive screen + node screen working
* tx history working and fiat fixes
* balance working
* derivation updates
* nano-unfinished
* sends working
* remove fees from send screen, send and receive transactions working
* fixes + auto receive incoming txs
* fix for scanning QR codes
* save
* update translations
* fixes
* more fixes
* more strings
* small fix
* fix github actions workflow
* potential fix
* potential fix
* ci/cd fix
* change rep working
* seed generation fixes
* fixes
* save
* change rep screen functional
* save
* banano changes
* fixes, start adding ui for PoW
* pow node changes
* update translations
* fix
* account changing barely working
* save
* disable account generation
* small fix
* save
* UI work
* save
* fixes after merge main
* fixes
* remove monero stuff, work on derivation ui
* lots of fixes + finish up seed derivation
* last minute fixes
* node related fixes
* more fixes
* small fix
* more fixes
* fixes
* pretty big refactor for pow, still some bugs
* finally works!
* get transactions after send
* fix
* merge conflict fixes
* save
* fix pow node showing up twice
* done
* initial changes
* small fix
* more merge fixes
* fixes
* more fixes
* fix
* save
* fix manage pow nodes setting appearing on other wallets
* fix contact bug
* fixes
* fiat fixes
* save
* save
* save
* save
* updates
* cleanup
* restore fix
* fixes
* remove deprecated alert
* fix
* small fix
* remove outdated warning
* electrum restore fixes
* fixes
* fixes
* fix
* derivation fixes
* nano fixes pt.1
* nano fixes pt.2
* bip39 fixes
* pownode refactor
* nodes pages fixes
* observer fix
* ssl fix
* remove old references
* remove unused imports
* code cleanup
* small fix
* small potential fix
* save
* derivation fixes
* deterministic fix
* fix pt.2
* derivation class fixes
* review fixes from nano that also apply here
* formatting
* stuff that should've stayed deleted
* post merge fixes
* remove problematic imports and duplicate changes
* Delete lib/nano/nano.dart
* move wallet restore page proxy code to the view model
* fix dashboard page indicators being the same color
* debatably better refactoring of derivationInfo, migration needed
* additional refactor improvements
* blanket comment some stuff out to narrow down this issue
* refactor fixes
* fix nano exchange
* fix , bug, i.e. replace , with . when making a nano transaction
* fix nano sending, update restore page wording, and other minor fixes
* write migration for existing bitcoin and nano wallets
* merge fixes
* minor fixes
* use default derivation type when restoring from qr code
* fixes for restoring
* fixes
* fixes
* merge fix
* Fix issues with Creating Electrum and Restoring Bip39
* updates & fixes
* Add missing case for no transactions BIP39 wallet restore
* Make the default BIP39 the 84 derivation path
* Add Samourai Deposit
* litecoin mnemonic error fix
* Bip39 passphrase support (#1412)
* save
* passphrase working
* fix for when loading wallets + translation update
* minor fix
* Fix Nano
* minor fix [skip ci]
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
* change error state seed conditions into throwables [skip ci]
* litecoin fixes
* Bip39 minor enhancements (#1416)
* minor enhancements
* rename bitcoin_derivations -> electrum_derivations
* Remove duplicate derivations
handle default case
* minor fix
* Enable passphrase for Litecoin
* obscure text of passphrase
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com>
Co-authored-by: fossephate <fosse@book.local>
2024-04-30 00:49:56 +00:00
' passphrase ' : passphrase ? ? ' ' ,
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-05-08 13:28:25 +00:00
' derivationTypeIndex ' : walletInfo . derivationInfo ? . derivationType ? . index ,
' derivationPath ' : walletInfo . derivationInfo ? . derivationPath ,
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
2024-04-17 19:35:11 +00:00
@ action
Future < void > updateAllUnspents ( ) 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
2024-04-17 19:35:11 +00:00
await Future . wait ( walletAddresses . allAddresses . map ( ( address ) async {
updatedUnspentCoins . addAll ( await fetchUnspent ( 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
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 ;
2024-05-09 20:06:39 +00:00
if ( coin . bitcoinAddressRecord is ! BitcoinSilentPaymentAddressRecord )
coin . bitcoinAddressRecord . balance + = coinInfo . value ;
2021-12-24 12:52:08 +00:00
} else {
_addCoinInfo ( coin ) ;
}
} ) ;
}
await _refreshUnspentCoinsInfo ( ) ;
}
2024-04-17 19:35:11 +00:00
@ action
Future < void > updateUnspents ( BitcoinAddressRecord address ) async {
final newUnspentCoins = await fetchUnspent ( address ) ;
if ( newUnspentCoins . isNotEmpty ) {
unspentCoins . addAll ( newUnspentCoins ) ;
newUnspentCoins . forEach ( ( coin ) {
final coinInfoList = unspentCoinsInfo . values . where (
( element ) = >
element . walletId . contains ( id ) & &
element . hash . contains ( coin . hash ) & &
element . vout = = coin . vout ,
) ;
if ( coinInfoList . isNotEmpty ) {
final coinInfo = coinInfoList . first ;
coin . isFrozen = coinInfo . isFrozen ;
coin . isSending = coinInfo . isSending ;
coin . note = coinInfo . note ;
2024-05-09 20:06:39 +00:00
if ( coin . bitcoinAddressRecord is ! BitcoinSilentPaymentAddressRecord )
coin . bitcoinAddressRecord . balance + = coinInfo . value ;
2024-04-17 19:35:11 +00:00
} else {
_addCoinInfo ( coin ) ;
}
} ) ;
}
}
@ action
Future < List < BitcoinUnspent > > fetchUnspent ( BitcoinAddressRecord address ) async {
final unspents = await electrumClient . getListUnspent ( address . getScriptHash ( network ) ) ;
List < BitcoinUnspent > updatedUnspentCoins = [ ] ;
await Future . wait ( unspents . map ( ( unspent ) async {
try {
final coin = BitcoinUnspent . fromJSON ( address , unspent ) ;
final tx = await fetchTransactionInfo ( hash: coin . hash , height: 0 ) ;
coin . isChange = address . isHidden ;
coin . confirmations = tx ? . confirmations ;
updatedUnspentCoins . add ( coin ) ;
} catch ( _ ) { }
} ) ) ;
return updatedUnspentCoins ;
}
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 ,
2024-04-17 19:35:11 +00:00
isSilentPayment: coin is BitcoinSilentPaymentsUnspent ,
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 ;
2024-04-18 00:26:42 +00:00
final tip = await getCurrentChainTip ( ) ;
2024-04-17 19:35:11 +00:00
if ( tip > 0 ) confirmations = height > 0 ? tip - 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 (
2024-04-17 19:35:11 +00:00
{ required String hash , required int height , 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 ,
2024-04-17 19:35:11 +00:00
addresses: addressesSet , height: height ) ;
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
} catch ( e ) {
if ( e is FormatException & & retryOnFailure = = true ) {
await Future . delayed ( const Duration ( seconds: 2 ) ) ;
2024-04-17 19:35:11 +00:00
return fetchTransactionInfo ( hash: hash , height: height ) ;
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
}
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 = { } ;
2024-04-17 19:35:11 +00:00
if ( type = = WalletType . bitcoin ) {
await Future . wait ( ADDRESS_TYPES
. map ( ( type ) = > fetchTransactionsForAddressType ( historiesWithDetails , type ) ) ) ;
} else if ( type = = WalletType . bitcoinCash ) {
await fetchTransactionsForAddressType ( historiesWithDetails , P2pkhAddressType . p2pkh ) ;
} else if ( type = = WalletType . litecoin ) {
await fetchTransactionsForAddressType ( historiesWithDetails , SegwitAddresType . p2wpkh ) ;
}
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
2024-04-12 22:33:00 +00:00
Future < void > fetchTransactionsForAddressType (
Map < String , ElectrumTransactionInfo > historiesWithDetails ,
BitcoinAddressType type ,
) async {
final addressesByType = walletAddresses . allAddresses . where ( ( addr ) = > addr . type = = type ) ;
final hiddenAddresses = addressesByType . where ( ( addr ) = > addr . isHidden = = true ) ;
final receiveAddresses = addressesByType . where ( ( addr ) = > addr . isHidden = = false ) ;
await Future . wait ( addressesByType . map ( ( addressRecord ) async {
2024-04-18 00:26:42 +00:00
final history = await _fetchAddressHistory ( addressRecord , await getCurrentChainTip ( ) ) ;
2024-04-12 22:33:00 +00:00
if ( history . isNotEmpty ) {
addressRecord . txCount = history . length ;
historiesWithDetails . addAll ( history ) ;
final matchedAddresses = addressRecord . isHidden ? hiddenAddresses : receiveAddresses ;
2024-04-17 19:35:11 +00:00
final isUsedAddressUnderGap = matchedAddresses . toList ( ) . indexOf ( addressRecord ) > =
matchedAddresses . length -
( addressRecord . isHidden
? ElectrumWalletAddressesBase . defaultChangeAddressesCount
: ElectrumWalletAddressesBase . defaultReceiveAddressesCount ) ;
2024-04-12 22:33:00 +00:00
2024-04-17 19:35:11 +00:00
if ( isUsedAddressUnderGap ) {
final prevLength = walletAddresses . allAddresses . length ;
// Discover new addresses for the same address type until the gap limit is respected
2024-04-12 22:33:00 +00:00
await walletAddresses . discoverAddresses (
matchedAddresses . toList ( ) ,
addressRecord . isHidden ,
2024-04-17 19:35:11 +00:00
( address ) async {
await _subscribeForUpdates ( ) ;
2024-04-18 00:26:42 +00:00
return _fetchAddressHistory ( address , await getCurrentChainTip ( ) )
2024-04-17 19:35:11 +00:00
. then ( ( history ) = > history . isNotEmpty ? address . address : null ) ;
} ,
2024-04-12 22:33:00 +00:00
type: type ,
) ;
2024-04-17 19:35:11 +00:00
final newLength = walletAddresses . allAddresses . length ;
if ( newLength > prevLength ) {
await fetchTransactionsForAddressType ( historiesWithDetails , type ) ;
}
2024-04-12 22:33:00 +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 (
2024-04-17 19:35:11 +00:00
BitcoinAddressRecord addressRecord , int ? currentHeight ) 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
try {
final Map < String , ElectrumTransactionInfo > historiesWithDetails = { } ;
2024-04-17 19:35:11 +00:00
final history = await electrumClient . getHistory ( addressRecord . getScriptHash ( 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
2024-04-17 19:35:11 +00:00
if ( currentHeight ! = null ) storedTx . confirmations = currentHeight - height + 1 ;
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
storedTx . isPending = storedTx . confirmations = = 0 ;
}
historiesWithDetails [ txid ] = storedTx ;
} else {
2024-04-17 19:35:11 +00:00
final tx = await fetchTransactionInfo ( hash: txid , height: height , retryOnFailure: 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
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 ) {
return ;
}
2024-04-17 19:35:11 +00:00
transactionHistory . transactions . values . forEach ( ( tx ) async {
if ( tx . unspents ! = null & & tx . unspents ! . isNotEmpty & & tx . height > 0 ) {
2024-04-18 00:26:42 +00:00
tx . confirmations = await getCurrentChainTip ( ) - tx . height + 1 ;
2024-04-10 21:05:36 +00:00
}
} ) ;
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-04-17 19:35:11 +00:00
Future < void > _subscribeForUpdates ( ) async {
final unsubscribedScriptHashes = walletAddresses . allAddresses . where (
( address ) = > ! _scripthashesUpdateSubject . containsKey ( address . getScriptHash ( network ) ) ,
) ;
await Future . wait ( unsubscribedScriptHashes . map ( ( address ) async {
final sh = address . getScriptHash ( network ) ;
2021-12-24 12:52:08 +00:00
await _scripthashesUpdateSubject [ sh ] ? . close ( ) ;
2024-04-17 19:35:11 +00:00
_scripthashesUpdateSubject [ sh ] = await 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 {
2024-04-17 19:35:11 +00:00
await updateUnspents ( address ) ;
final newBalance = await _fetchBalance ( sh ) ;
balance [ currency ] ? . confirmed + = newBalance . confirmed ;
balance [ currency ] ? . unconfirmed + = newBalance . unconfirmed ;
2024-04-18 00:26:42 +00:00
await _fetchAddressHistory ( address , await getCurrentChainTip ( ) ) ;
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-04-17 19:35:11 +00:00
} ) ) ;
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
2024-04-17 19:35:11 +00:00
transactionHistory . transactions . values . forEach ( ( tx ) {
if ( tx . unspents ! = null ) {
tx . unspents ! . forEach ( ( unspent ) {
if ( unspent . bitcoinAddressRecord is BitcoinSilentPaymentAddressRecord ) {
if ( unspent . isFrozen ) totalFrozen + = unspent . value ;
totalConfirmed + = unspent . value ;
2024-04-01 21:07:49 +00:00
}
2024-04-17 19:35:11 +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
}
2024-04-17 19:35:11 +00:00
Future < ElectrumBalance > _fetchBalance ( String sh ) async {
final balance = await electrumClient . getBalance ( sh ) ;
final confirmed = balance [ ' confirmed ' ] as int ? ? ? 0 ;
final unconfirmed = balance [ ' unconfirmed ' ] as int ? ? ? 0 ;
return ElectrumBalance ( confirmed: confirmed , unconfirmed: unconfirmed , frozen: 0 ) ;
}
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
2024-05-05 01:44:50 +00:00
Future < String > signMessage ( String message , { String ? address = null } ) async {
2023-09-14 19:14:49 +00:00
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-04-17 19:35:11 +00:00
if ( _chainTipUpdateSubject ! = null ) return ;
2024-05-11 13:14:14 +00:00
_chainTipUpdateSubject = electrumClient . chainTipSubscribe ( ) ;
2024-04-17 19:35:11 +00:00
_chainTipUpdateSubject ? . listen ( ( e ) async {
final event = e as Map < String , dynamic > ;
final height = int . parse ( event [ ' height ' ] . toString ( ) ) ;
_currentChainTip = height ;
if ( _currentChainTip ! = null & & _currentChainTip ! > 0 & & walletInfo . restoreHeight = = 0 ) {
2024-05-09 20:06:39 +00:00
await walletInfo . updateRestoreHeight ( _currentChainTip ! ) ;
2024-04-17 19:35:11 +00:00
}
2024-05-10 22:23:05 +00:00
2024-05-11 13:14:14 +00:00
if ( alwaysScan = = true & & syncStatus is SyncedSyncStatus ) {
2024-05-10 22:23:05 +00:00
_setListeners ( walletInfo . restoreHeight ) ;
}
2024-04-17 19:35:11 +00:00
} ) ;
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-05-05 01:44:50 +00:00
static String _hardenedDerivationPath ( String derivationPath ) = >
derivationPath . substring ( 0 , derivationPath . lastIndexOf ( " ' " ) + 1 ) ;
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-12 18:28:01 +00:00
final List < int > labelIndexes ;
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-12 18:28:01 +00:00
required this . labelIndexes ,
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-12 18:28:01 +00:00
labelIndexes: scanData . labelIndexes ,
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 {
2024-05-09 20:06:39 +00:00
int syncHeight = scanData . height ;
int initialSyncHeight = syncHeight ;
2024-02-26 18:33:31 +00:00
2024-04-17 19:35:11 +00:00
BehaviorSubject < Object > ? tweaksSubscription = null ;
2024-02-26 18:33:31 +00:00
2024-05-09 20:06:39 +00:00
final syncingStatus = scanData . isSingleScan
? SyncingSyncStatus ( 1 , 0 )
: SyncingSyncStatus . fromHeightValues ( scanData . chainTip , initialSyncHeight , syncHeight ) ;
2024-02-26 18:33:31 +00:00
2024-05-09 20:06:39 +00:00
// Initial status UI update, send how many blocks left to scan
2024-04-17 19:35:11 +00:00
scanData . sendPort . send ( SyncResponse ( syncHeight , syncingStatus ) ) ;
2024-02-26 18:33:31 +00:00
2024-05-09 20:06:39 +00:00
final electrumClient = scanData . electrumClient ;
await electrumClient . connectToUri ( scanData . node . uri , useSSL: scanData . node . useSSL ) ;
if ( tweaksSubscription = = null ) {
final count = scanData . isSingleScan ? 1 : TWEAKS_COUNT ;
final receiver = Receiver (
scanData . silentAddress . b_scan . toHex ( ) ,
scanData . silentAddress . B_spend . toHex ( ) ,
scanData . network = = BitcoinNetwork . testnet ,
scanData . labelIndexes ,
scanData . labelIndexes . length ,
) ;
2024-02-27 14:40:56 +00:00
2024-05-09 20:06:39 +00:00
tweaksSubscription = await electrumClient . tweaksSubscribe ( height: syncHeight , count: count ) ;
tweaksSubscription ? . listen ( ( t ) async {
final tweaks = t as Map < String , dynamic > ;
if ( tweaks [ " message " ] ! = null ) {
// re-subscribe to continue receiving messages
electrumClient . tweaksSubscribe ( height: syncHeight , count: count ) ;
return ;
}
2024-04-05 20:27:42 +00:00
2024-05-09 20:06:39 +00:00
final blockHeight = tweaks . keys . first ;
final tweakHeight = int . parse ( blockHeight ) ;
2024-04-18 11:57:16 +00:00
2024-02-27 14:40:56 +00:00
try {
2024-05-09 20:06:39 +00:00
final blockTweaks = tweaks [ blockHeight ] as Map < String , dynamic > ;
2024-04-17 19:35:11 +00:00
2024-05-09 20:06:39 +00:00
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-17 19:35:11 +00:00
2024-05-09 20:06:39 +00:00
try {
// scanOutputs called from rust here
final addToWallet = scanOutputs (
outputPubkeys . values . toList ( ) ,
tweak ,
receiver ,
) ;
if ( addToWallet . isEmpty ) {
// no results tx, continue to next tx
continue ;
}
2024-04-05 20:27:42 +00:00
2024-05-09 20:06:39 +00:00
// placeholder ElectrumTransactionInfo object to update values based on new scanned unspent(s)
final txInfo = ElectrumTransactionInfo (
WalletType . bitcoin ,
id: txid ,
height: tweakHeight ,
amount: 0 ,
fee: 0 ,
direction: TransactionDirection . incoming ,
isPending: false ,
date: scanData . network = = BitcoinNetwork . mainnet
? getDateByBitcoinHeight ( tweakHeight )
: DateTime . now ( ) ,
confirmations: scanData . chainTip - tweakHeight + 1 ,
unspents: [ ] ,
) ;
addToWallet . forEach ( ( label , value ) {
( value as Map < String , dynamic > ) . forEach ( ( output , tweak ) {
final t_k = tweak . toString ( ) ;
final receivingOutputAddress = ECPublic . fromHex ( output )
. toTaprootAddress ( tweak: false )
. toAddress ( scanData . network ) ;
int ? amount ;
int ? pos ;
outputPubkeys . entries . firstWhere ( ( k ) {
final isMatchingOutput = k . value [ 0 ] = = output ;
if ( isMatchingOutput ) {
amount = int . parse ( k . value [ 1 ] . toString ( ) ) ;
pos = int . parse ( k . key . toString ( ) ) ;
return true ;
}
return false ;
} ) ;
2024-02-26 18:33:31 +00:00
2024-05-09 20:06:39 +00:00
final receivedAddressRecord = BitcoinSilentPaymentAddressRecord (
receivingOutputAddress ,
index: 0 ,
isHidden: false ,
isUsed: true ,
network: scanData . network ,
silentPaymentTweak: t_k ,
type: SegwitAddresType . p2tr ,
txCount: 1 ,
balance: amount ! ,
2024-04-17 19:35:11 +00:00
) ;
2024-05-09 20:06:39 +00:00
final unspent = BitcoinSilentPaymentsUnspent (
receivedAddressRecord ,
txid ,
amount ! ,
pos ! ,
silentPaymentTweak: t_k ,
silentPaymentLabel: label = = " None " ? null : label ,
2024-04-17 19:35:11 +00:00
) ;
2024-05-09 20:06:39 +00:00
txInfo . unspents ! . add ( unspent ) ;
txInfo . amount + = unspent . value ;
} ) ;
} ) ;
2024-04-17 19:35:11 +00:00
2024-05-09 20:06:39 +00:00
scanData . sendPort . send ( { txInfo . id: txInfo } ) ;
2024-04-17 19:35:11 +00:00
} catch ( _ ) { }
}
2024-05-09 20:06:39 +00:00
} catch ( _ ) { }
2024-02-26 18:33:31 +00:00
2024-05-09 20:06:39 +00:00
syncHeight = tweakHeight ;
scanData . sendPort . send (
SyncResponse (
syncHeight ,
SyncingSyncStatus . fromHeightValues (
scanData . chainTip ,
initialSyncHeight ,
syncHeight ,
) ,
) ,
2024-04-17 19:35:11 +00:00
) ;
2024-05-09 20:06:39 +00:00
if ( tweakHeight > = scanData . chainTip | | scanData . isSingleScan ) {
2024-05-10 22:23:05 +00:00
scanData . sendPort . send ( SyncResponse (
syncHeight ,
SyncedTipSyncStatus ( scanData . chainTip ) ,
) ) ;
2024-05-09 20:06:39 +00:00
await tweaksSubscription ! . close ( ) ;
2024-05-11 13:14:14 +00:00
await electrumClient . close ( ) ;
2024-05-09 20:06:39 +00:00
}
} ) ;
}
if ( tweaksSubscription = = null ) {
return scanData . sendPort . send (
SyncResponse ( syncHeight , UnsupportedSyncStatus ( ) ) ,
) ;
2024-02-26 18:33:31 +00:00
}
}
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-05-05 01:44:50 +00:00
required this . publicKeys ,
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-26 19:29:31 +00:00
required this . spendsUnconfirmedTX ,
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-05-05 01:44:50 +00:00
final Map < String , PublicKeyWithDerivationPath > publicKeys ; // PubKey to derivationPath
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-26 19:29:31 +00:00
final bool spendsUnconfirmedTX ;
2024-02-26 18:32:54 +00:00
}
2024-05-05 01:44:50 +00:00
class PublicKeyWithDerivationPath {
const PublicKeyWithDerivationPath ( this . publicKey , this . derivationPath ) ;
final String derivationPath ;
final String publicKey ;
}
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 ;
}
}
2024-04-18 13:38:18 +00:00
class UtxoDetails {
final List < BitcoinUnspent > availableInputs ;
2024-05-06 13:19:03 +00:00
final List < BitcoinUnspent > unconfirmedCoins ;
2024-04-18 13:38:18 +00:00
final List < UtxoWithAddress > utxos ;
final List < Outpoint > vinOutpoints ;
final List < ECPrivateInfo > inputPrivKeyInfos ;
2024-05-06 15:14:58 +00:00
final Map < String , PublicKeyWithDerivationPath > publicKeys ; // PubKey to derivationPath
2024-04-18 13:38:18 +00:00
final int allInputsAmount ;
final bool spendsSilentPayment ;
2024-05-06 13:19:03 +00:00
final bool spendsUnconfirmedTX ;
2024-04-18 13:38:18 +00:00
UtxoDetails ( {
required this . availableInputs ,
2024-05-06 13:19:03 +00:00
required this . unconfirmedCoins ,
2024-04-18 13:38:18 +00:00
required this . utxos ,
required this . vinOutpoints ,
required this . inputPrivKeyInfos ,
2024-05-06 15:14:58 +00:00
required this . publicKeys ,
2024-04-18 13:38:18 +00:00
required this . allInputsAmount ,
required this . spendsSilentPayment ,
2024-05-06 13:19:03 +00:00
required this . spendsUnconfirmedTX ,
2024-04-18 13:38:18 +00:00
} ) ;
}