mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
+4








084fd6bb1e
* refactor node form UI to use new ListItem model * add new list item row types and widgets * add style wrapper * remove print [skip ci] * Integrate new design mockup with ViewModel (#2653) * feat: add Lightning Network support for Bitcoin wallets * refactor: rename `fiatConvertationStore` to `fiatConversionStore` for consistency and update related occurrences across codebase * feat: enhance address validation with Lightning Network invoice support for BTC & refactor wallet type/token checks in view model * feat: add support for Lightning invoice detection, refactor MWEB deposit/withdraw actions, and integrate Lightning transaction creation with updated priority handling * feat: add method to retrieve unused Spark deposit address for Bitcoin wallets * feat: add Breez API key support and update secrets handling for Bitcoin Lightning wallet integration in workflows * chore: update Breez SDK dependency to version 0.3.4 in pubspec files * Add bitcoin secrets config [skip ci] * feat: extend Lightning wallet functionality with transaction history fetching * feat: add LNURL-pay address detection and support in address parsing flow for Bitcoin Lightning integration * refactor: simplify `ReceivePageOption` logic * refactor: centralize `PaymentURI` generation logic across wallet types * feat: enhance `PaymentURI` handling with asynchronous support and Lightning-specific functionality * refactor: streamline `PaymentURI` logic and remove redundant URI implementations across wallet types * refactor: remove redundant debug print statement from `bitcoin_wallet_addresses.dart` * refactor: improve consistency in widget styling and centralized label logic, add Bitcoin Lightning deposit/withdraw support * feat: reload balance and tx history after sending a lightning transaction * feat: improve address formatting for human-readable addresses and update the default LNURL domain * fix: merge conflicts * feat: add error handling for LightningWallet initialization and adjust transaction direction logic * integrate homepage from new ui mockup * fix import * feat: add Lightning Network support for Bitcoin wallets * refactor: rename `fiatConvertationStore` to `fiatConversionStore` for consistency and update related occurrences across codebase * feat: enhance address validation with Lightning Network invoice support for BTC & refactor wallet type/token checks in view model * feat: add support for Lightning invoice detection, refactor MWEB deposit/withdraw actions, and integrate Lightning transaction creation with updated priority handling * feat: add method to retrieve unused Spark deposit address for Bitcoin wallets * feat: add Breez API key support and update secrets handling for Bitcoin Lightning wallet integration in workflows * chore: update Breez SDK dependency to version 0.3.4 in pubspec files * Add bitcoin secrets config [skip ci] * feat: extend Lightning wallet functionality with transaction history fetching * feat: add LNURL-pay address detection and support in address parsing flow for Bitcoin Lightning integration * refactor: simplify `ReceivePageOption` logic * refactor: centralize `PaymentURI` generation logic across wallet types * feat: enhance `PaymentURI` handling with asynchronous support and Lightning-specific functionality * refactor: streamline `PaymentURI` logic and remove redundant URI implementations across wallet types * refactor: remove redundant debug print statement from `bitcoin_wallet_addresses.dart` * refactor: improve consistency in widget styling and centralized label logic, add Bitcoin Lightning deposit/withdraw support * feat: reload balance and tx history after sending a lightning transaction * feat: improve address formatting for human-readable addresses and update the default LNURL domain * fix: merge conflicts * feat: add error handling for LightningWallet initialization and adjust transaction direction logic * integrate homepage from new ui mockup * fix import * add new-ui dir to pubspec_base * minor layout fixes * cleanup navbar logic * Modify navbar behaviour * smooth color change when selecting navbar options * open old ui pages with new ui action buttons * feat: working navbar in new ui * fix: minor sizing tweaks * CW-1266-integrate-bitcoin-lightning-through-spark-sdk (#2623) * feat: add Lightning Network support for Bitcoin wallets * refactor: rename `fiatConvertationStore` to `fiatConversionStore` for consistency and update related occurrences across codebase * feat: enhance address validation with Lightning Network invoice support for BTC & refactor wallet type/token checks in view model * feat: add support for Lightning invoice detection, refactor MWEB deposit/withdraw actions, and integrate Lightning transaction creation with updated priority handling * feat: add method to retrieve unused Spark deposit address for Bitcoin wallets * feat: add Breez API key support and update secrets handling for Bitcoin Lightning wallet integration in workflows * chore: update Breez SDK dependency to version 0.3.4 in pubspec files * Add bitcoin secrets config [skip ci] * feat: extend Lightning wallet functionality with transaction history fetching * feat: add LNURL-pay address detection and support in address parsing flow for Bitcoin Lightning integration * refactor: simplify `ReceivePageOption` logic * refactor: centralize `PaymentURI` generation logic across wallet types * feat: enhance `PaymentURI` handling with asynchronous support and Lightning-specific functionality * refactor: streamline `PaymentURI` logic and remove redundant URI implementations across wallet types * refactor: remove redundant debug print statement from `bitcoin_wallet_addresses.dart` * refactor: improve consistency in widget styling and centralized label logic, add Bitcoin Lightning deposit/withdraw support * feat: reload balance and tx history after sending a lightning transaction * feat: improve address formatting for human-readable addresses and update the default LNURL domain * fix: merge conflicts * feat: add error handling for LightningWallet initialization and adjust transaction direction logic * feat: enable private transactions by default in LightningWallet and update Breez SDK version to 0.4.2 * minor fixes [skip ci] * chore: fix some minor issues in comments (#2654) Signed-off-by: black5box <black5box@outlook.com> * fix: handle send-all functionality for LightningWallet transactions and adjust amount calculation logic * fix-german (#2659) * chore: update German localization strings for consistency and accuracy * chore: update German localization strings for consistency and accuracy [skip-ci] * feat: add LNURL support for address validation and LightningWallet compatibility, enhance error handling for OpenCryptoPay * fix: adjust LightningWallet amount parsing from 9 to 8 decimal places * feat: add LNURL support in LightningPaymentRequest and LightningWallet * Fix navigation gradient (#2657) * Fix navigation gradient * Fix CONFIG_ARGS formatting in app_config.sh (#2660) * fix: block wrongly parsed addresses (#2656) * fix: block wrongly parsed addresses * fix: move parsed address check into handlePaymentFlow method * fix: Handle QR URLs separately for pay anything flow * feat: add electrum seed support for Lightning * refactor: improve `parseFixed` logic and add comprehensive unit tests for edge cases (#2661) * Update cw_bitcoin/lib/bitcoin_wallet.dart [skip ci] * resolve conflict issue --------- Signed-off-by: black5box <black5box@outlook.com> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> Co-authored-by: black5box <black5box@outlook.com> Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: cyan <cyjan@mrcyjanek.net> Co-authored-by: David Adegoke <64401859+Blazebrain@users.noreply.github.com> * remove old code [skip ci] * fix: page widgets rebuilt every time * chore: formatting * remove unused navbar * fix: lightning balance on balance card in lightning mode * fix: return if uri == null * feat: trade history in new ui * feat: enhance balance model with secondary asset handling * feat: unique card colors and icons for coins * wip: card customization * fix: merge conflict * feat: customizable balance card * Fix some spacings and test sizing * Fix formatting * feat: add Lightning Network support for send flow and fee handling adjustments * refactor: remove unnecessary debug print statement in send flow for Lightning Network balance * feat: integrate OpenCryptoPay QR handling in send flow and improve scan action handling logic * feat: add maxDepositClaimFee parameter for Lightning wallet configuration * Switch balance card to RoundedSuperellipse and set color list to Wrap * Fix * Switch to scroll view * refactor: update navigation route from `receive` to `addressPage` in coin action row * feat: bloc-based viewmodel for card customizer * feat: mobx-independent balance card customizer vm * minor fixes * copyWith constructor for cleaner state changes * refactor: wrap `HistorySection` with `Observer` for reactive state updates, update navigation for "Buy" action, and fix incorrect balance property * feat: enhance Bitcoin receive flow with Lightning and SegWit options, update address page registration, and localize coin action labels * feat: add helper methods for Lightning and SegWit receive page options in Bitcoin configuration * feat: add Lightning transaction type handling and enable navigation to transaction details from history * Add more special card types * feat: new ui settings page * feat: add Lightning actions to balance cards, refactor card rendering logic * refactor: update settings page localization, hide unused settings items * feat: add secrets generation for cw_bitcoin, including breezApiKey * Lightning switcher animation (#2725) * Properly animate bitcoin/lightning switcher * Cleanup and fix sizing * Final cleanup * Fix action button colors (#2732) * feat: add hardware wallet type handling and improve parsed address reset flow * Refactor settings page to use generic row items (#2745) * fix android back button in settings on android, force iphone-style transitions on all platforms * move settings page to generic row impl * fix imports * Balance card fixes (#2729) * Update balance card sizing * Fix spacing * Initial font changes (#2731) * Initial font changes * More font changes * feat: integrate Lightning transaction support and improve transaction history UX - Enhanced dashboard to compute confirmations using the first and last transactions. - Updated `BitcoinWallet` to subscribe for and manage Lightning transactions. - Improved `HistoryTile` layout and introduced new leading icons for Lightning transactions. * feat: add unclaimed deposit actions and enhance Lightning event handling * release changes [skip ci] * Enhanced card customizer (#2744) * enhanced card customizer * Fix conflicts * Add missing icons + adjust spacing --------- Co-authored-by: tuxsudo <tuxsudo@tux.pizza> * feat: enhance Lightning invoice handling and address validation - Added support for identifying non-zero amount Lightning invoices. - Refined invoice matching with updated regex patterns. - Improved UI to conditionally display addresses in sending confirmations. - Adjusted logic to handle zero-value Lightning invoices. * feat: add `isPayjoinAvailable` computed property and update Payjoin visibility logic * feat: improve Lightning wallet handling and block explorer logic * update patch version [skip ci] --------- Signed-off-by: black5box <black5box@outlook.com> Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: black5box <black5box@outlook.com> Co-authored-by: cyan <cyjan@mrcyjanek.net> Co-authored-by: David Adegoke <64401859+Blazebrain@users.noreply.github.com> * minor new ui fixes * padding for new row separators * remove debug prints * New design improve nav bar (#2763) * tweak navigation bar touch targets and sizing * feat: add tests for identifying zero and non-zero amount Lightning invoices (#2772) * feat: add tests for identifying zero and non-zero amount Lightning invoices - Added unit tests to validate recognition of Bolt11 zero-amount and non-zero-amount invoices. - Enhanced `isBolt11ZeroInvoice` function to handle `lightning:` prefixed invoices. * fix: correct currency selection logic for Lightning wallets in Send ViewModel * feat: improve Lightning wallet initialization and address generation - Updated `init` method in `LightningWallet` to return a boolean for initialization success, adding error handling for failed setups. - Integrated dynamic name generation using `generateName` for Lightning wallet addresses. * refactor: relocate `generate_name` to `cw_core` and update imports * chore: update breez sdk (#2789) * Wire tokens and NFTs to new Home page (#2804) * wiring for assets on home page * fix imports * wire nft page in new ui * fix nft display in new ui * fix totalWidth calc * add tokens button + bugfixes * add tokens button + bugfixes * fix late initialization * fix history section exception * fixes * Add haptic feedback (#2813) * Add haptic feedback * Add haptic feedback to correct ActionButton * Return bottom gradient (#2808) * Add IgnorePointer to bottom nav gradient (#2822) * New design send page (#2791) * new ui send page (wip) * coin control page improvements * fee settings, new send confirmation modal * minor aesthetic fixes * load network name without cw_bitcoin import * recipient dot cleanup * minor logic fixes * ui polish * - add aliaspay support - fix wording for max button - fix back button action in modals * Sizing changes * dismiss transaction on modal close * sizing fix * - fix remove recipient icon - properly round amounts - fix coin control page spacing * - fix remove recipient icon - properly round amounts - fix coin control page spacing * - fix button sizing - add description for fees page * Update lib/view_model/unspent_coins/unspent_coins_list_view_model.dart [skip ci] * Update lib/view_model/send/send_view_model.dart [skip ci] --------- Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Fix conflicts with dev * Fix conflicts with dev * Add zcash receive options to new design flow * wire in missing settings in new ui * up migration version * formatting * translations * lint.sh * New design receive page (#2834) * feat: viewmodel on new receive page (wip) * feat: address type selector for new ui receive page * fix: minor fixes to touch targets and tap anims * minor ui fix * wip receive page changes * receive page + address selection page * receive page + address selection page * add font * add svg * minor ui fixes * receive page fixes/improvements * change receive page modal design * further ui polish * icons for infobox * fix restricted import * fix closing label modal * - fix balance card appearance on address page - fix search bar position - fix mweb position in address type selector * receive page fixes * fix anonpay * remove restricted import * fixes * fix receive on zec * simplify chain id * lint fix * fix migration numbering Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fix migration version Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fix settings * readability * fix formatting * move dismiss infobox to vm * disable addr rotation on zcash * remove _setEffects * translations --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * New UI Sync bar (#2831) * syncbar * small styling fixes * modify duration * lint.sh * syncHeavy wallet types Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * update translations, add pull-down refresh, separate top bar components to files --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * alphabetize * New design balance card icons (#2824) * Add the other crypto card icons * Update Zano, add Zcash and Arbitrum * Update default card style and available gradients * Fix broken preview * Fix animation * Color combinations fix * Minor updates * Add decred icon * if(!mounted) return; * New design minor fixes (#2842) * More minor fixes * Update modal sheet behaviour * Update missing currency image links * List row and navigation bar tweaks * Minor navbar fix * New UI Swap page (#2829) * new ui send page (wip) * coin control page improvements * fee settings, new send confirmation modal * minor aesthetic fixes * load network name without cw_bitcoin import * recipient dot cleanup * minor logic fixes * ui polish * - add aliaspay support - fix wording for max button - fix back button action in modals * Sizing changes * dismiss transaction on modal close * sizing fix * - fix remove recipient icon - properly round amounts - fix coin control page spacing * - fix remove recipient icon - properly round amounts - fix coin control page spacing * - fix button sizing - add description for fees page * swap page * fixes * further fixes * merge * png -> svg * minor condition changes * lint.sh * fix swapsxyz isCentralized Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * translations, readability improvements, remove debug rows * cleanup * alphabetize strings * small bugfixes --------- Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fix new ui coin control page layout (#2843) * New design lightning flows (#2821) * new ui send page (wip) * coin control page improvements * fee settings, new send confirmation modal * minor aesthetic fixes * load network name without cw_bitcoin import * recipient dot cleanup * minor logic fixes * ui polish * - add aliaspay support - fix wording for max button - fix back button action in modals * Sizing changes * dismiss transaction on modal close * sizing fix * - fix remove recipient icon - properly round amounts - fix coin control page spacing * - fix remove recipient icon - properly round amounts - fix coin control page spacing * - fix button sizing - add description for fees page * lightning flow wip * lightning flow wip #2 * lightning withdraw flow * lightning deposit flow (wip, currently works but really janky) * send from external + bugfixes * merge fixes * merge fixes * fixes * Update lib/new-ui/widgets/send_page/l2_action_wallet_selector.dart --------- Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fix covered create wallet button * fix: close modal after transaction commitment in Send ViewModel (#2858) * New design tweaks (#2847) * Add more haptic feedback * Fix background gradients and modify SafeArea in home_page.dart * Fix history padding, fix divider color, disable Charts, update base_page.dart appbar style, fix nav bar border + height on iOS * Lightning Username setup flow for new UI (#2845) * lightning username edit/create flow * fix button color * fix layout * fixes * remove character limitation for internal builds * remove dependency on cw_bitcoin * fix username requirements * fixes * condition fix * Update lib/new-ui/pages/lightning_username_page.dart --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> * keyboard hide overlay for iphone * New design UI tweaks (#2870) * Fix nav height on Android * Fix blue gradient * Update transactions view and minor UI tweaks * CW1011-Allow-users-to-view-bitcoin-amounts-in-sats (#2678) * feat: introduce `formatFixed` integration and sats display preference * feat: enable display of Bitcoin amounts in satoshis and refactor amount formatting logic * refactor: consolidate fee formatting logic and add support for MWEB availability check * feat: add support for satoshi-based amount display and enhance fiat conversion logic * feat: add support for satoshi-based amount parsing, formatting, and display preferences across buy/sell flow and UI adjustments * feat: implement `AmountParsingProxy` with unit tests for parsing and formatting crypto amounts in various display modes * feat: replace `preferBalanceInSats` with `displayAmountsInSatoshi` and introduce `AmountParsingProxy` for unified crypto amount handling across the app * refactor: streamline amount formatting logic and enhance unspent coins handling with `AmountParsingProxy` integration for unified crypto processing * refactor: replace direct bitcoin amount formatting with `AmountParsingProxy` and remove debug print in `exchange_view_model` * refactor: replace `getIt<AmountParsingProxy>` with `_appStore.amountParsingProxy`, remove redundant dependencies across view models and adjust related imports * refactor: remove redundant `AmountParsingProxy` registration in DI setup to simplify dependency management [skip ci] * feat: add getCryptoSymbol to simplify the Symbol selection between Sats and Bitcoin * fix: merge conflict * Revert "fix: merge conflict" This reverts commit 6debdaa0466747d6fcc85d6bd0be115e6fb4d856. * fix import [skip ci] * feat: remove number formatter from exchangeVM * refactor: replace `SettingsStore` with `AppStore` across view models, integrate `AmountParsingProxy` for amount formatting, and clean up redundant imports * refactor: remove debug print statements from `getCryptoOutputAmount` in `AmountParsingProxy` * feat: enhance fee and deposit amount formatting with crypto symbols and improved parsing * feat: integrate `AmountParsingProxy` for improved Bitcoin amount parsing in `PaymentURI` and fiat-to-crypto conversion * feat: append crypto symbols to Bitcoin transaction amounts in dashboard view * feat: improve crypto amount parsing in SendCard widget and Output view model using `AmountParsingProxy` * feat: conditionally show Bitcoin amount display setting for Bitcoin wallets and refactor `DisplaySettingsViewModel` to use `AppStore` * refactor: clean up redundant imports in `bitcoin_wallet.dart` and `electrum_wallet.dart` * feat: append crypto symbols to fee values in send and cake pay card widgets for improved clarity * refactor: replace `currencyTitle` with `currency` across widgets and integrate `AmountParsingProxy` for improved crypto amount formatting and parsing * refactor: improve validation logic and amount parsing in SendCard and Output widgets * refactor: standardize amount parsing and formatting logic with `AmountParsingProxy` across ViewModels and widgets * refactor: `AppStore` remove debug prints * refactor: rename amount parsing/formatting methods for better clarity in tests [skip ci] * fix: AmountParsingProxy and optimize `cryptoAmount` handling in BuySellViewModel * fix: adjust balance calculation for Monero and Wownero to exclude unlocked amount from full balance * fix: correct `_appStore` usage and format adjustments in `SendViewModel` * feat: enhance satoshi on new-ui * feat: add computed property for `amountParsingProxy` in AppStore * feat: localize Bitcoin amount display option and update asset history UI * feat: improve exchange amount processing and refactor fiat conversion values --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> * New design unconfirmed balance widget (#2861) * unconfirmed balance display widget for new ui * unconfirmed balance display widget for new ui * merge * alphabetize translations * New UI fixes (#2860) * fix asset top bar * improve wordmark in large qr mode on receive * receive option fixes * exchange -> swap * send page fixes * update pubspec base * go to home on wallet change * nicer card customizer * don't show account name for single-account wallets * special card design for lightning * fiat amount bar improvement * update translations * add sending indicator * fix non-number input to receive amount * de-jank fiat input * nicer balance card animation when switching btc-ln * nicer balance card animation when switching btc-ln * fix backup password input * display time+date in history * fix error on buy * fix incorrect wallet showing in wallets tab * fix wallet list layout * only show coin control option on hasCoinControl * better error on send page * fiat value in coin control * add zano to isSyncHeeavy * fix keys in settings * fix assets condition * fix import * remove BasePage dependency in RescanPage * add missing settings * show send/receive in swap confirm sheet * fix receive background on ios * fix assets spacing * fix trade tile sizing * fix padding * fix icon in wallet select modal * change text on swap initial modal * spacing * l2 send external modal styling * fix null on swap confirm sheet * change infobox text * add chain icon to asset widgets * add chain icon to asset widgets * disable swap page reset * fix wallet list page layout * revert merge conflict issue [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Account Customizer for new UI Monero (#2859) * new ui monero account management (wip) * account reordering wip * account reordering wip * account reordering (works) * cards view compact mode * format * translation * name generation * fix for non-xmr wallets * } * allow reset order, fallback on improperly saved order * translation * fix for pre-reorder wallet loading * fix loading * - save cards on modal slide-down - always load active account as first * fix card customizer close anim * fixes * fix condition * merge * fix migration versions * use updated flutter rust bridge in lightning and payjoin * mvp fixes * new ui mweb mask/unmask * fallback for balance card amount format * New UI tweaks (#2872) * Update lightning transaction history view * Add BNB card design * Color, padding, and radius fixes * Fix wallet list bottom section & gradient * Update Apps page * reformat * nicer sat picker * fix keyboard * chain badges * enhance styling for card customizer * mweb settings icon * mweb chain badge * update wording in settings * bnb chain icon * always round send amount * always round all amount * token placeholder * Fix ModernButton colors (#2888) * Fix ModernButton colors * Minor * guard for unconfirmed balance widget * fix error on wallet switch * New design mvp fixes (#2890) * mvp fixes * fallback for balance card amount format * reformat * nicer sat picker * fix keyboard * chain badges * enhance styling for card customizer * bnb chain icon * always round send amount * always round all amount * guard for unconfirmed balance widget * fix error on wallet switch * Update lib/new-ui/pages/account_customizer.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fixes --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Install Protoc in reusable build workflow Added step to install Protoc before building. * Fix protobuf-compiler installation step Update package list before installing protobuf-compiler. * Modify Protoc installation command to handle update errors Change the install command for Protoc to avoid failure on update. * Streamline Lightning wallet balance management and crypto handling (#2893) * refactor: streamline crypto amount handling and improve Lightning balance management - Removed redundancy in balance calculations for Lightning wallets. - Centralized crypto symbol creation with `selectedCryptoCurrencySymbol`. - Enhanced crypto amount handling and formatting with `AmountParsingProxy`. - Simplified logic for displaying Lightning balances across UI components. * refactor: remove sats display logic and unused formatting from BalanceCard widget * chore: update breez-sdk-spark-flutter to latest commit * feat: enhance crypto amount formatting with localized separators and max decimals * fixes * fix: handle null balance records in Lightning wallet cards * New design add validators (#2894) * add validation, fix node form * Add validator to send amount input field Added a validator to the amount input field. --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Disable 'addresses' button on receive screen for BTC LN (#2896) * feat: Disable addresses button on receive screen for BTC LN * chore: remove debug print in uri computation * feat: introduce swap action toggle and UI updates * feat: conditionally display Zcash card setting for Zcash wallets in Display Settings * Fix leading button color (#2898) * fix amount format * fix loadCards * pre-beta fixes * cyjan: fix: order being null for certain index * pre-beta fixes v2 (#2905) * minor context check [skip ci] * persist fee priority for zcash (#2907) * Add support for Zcash address detection and amount logic refactor (#2906) * refactor: consolidate crypto amount handling with `displayAmount` and `cryptoCurrencySymbol`, improve fiat conversion logic, and optimize token currency management * refactor: simplify `displayAmount` logic and remove unused `_rawAmount` property * feat: add support for Zcash transparent address detection and simplify amount conversion logic * Improve Lightning invoice handling and crypto formatting (#2908) * fix: update Lightning address regex to support additional formats and prefixes * fix: conditionally render advanced settings dropdown based on fees or coin control availability * feat: enhance address detection, Lightning invoice handling, and crypto formatting * feat: improve Lightning invoice parsing and crypto amount formatting on send page * chore: remove unnecessary exception printing in `getBolt11Amount` function * Fix lightning swap * import fix (hide Mac;) * parse -> tryParse * Transaction Commited -> Transaction Sent! * feat: enable clipboard paste for deposit and receive addresses in swap page (#2909) * fix: resolving LNURLS (#2911) * new UI pre-beta fixes (#2910) * fixes * parse -> tryParse * change sat display settings style * minor fix until hive is removed [skip ci] * Remove redundant logic and improve send page features (#2913) * fix: update crypto amount parsing logic in send confirmation sheet * feat: Added checkbox to toggle Litecoin MWEB coins on the send page. fix: LNUrlPayRecord * fix: remove redundant `.withLocalSeperator()` from fiat balance formatting logic * fix: update Bitcoin amount display titles to align with consistent formatting standards * force boolean to update (#2916) * force boolean to update * fix bnb balance * fixes #4 (#2917) * only display sats for btc wallets in card customizer * fix: resolve async handling of Lightning transaction history in `fetchTransactions` method (#2919) * New design pre beta fixes 5 (#2918) * improve l2 deposit/withdraw flow layouts * add copied indicator * SafeArea * fix addr rotation * fix styling of lightning switcher * no raster graphics in new ui please * optimization for assets/history section * remove unused bloc provider * optimize dashboard + fix duplicated name * disable lightning mode on wallet change * remove broken animation * safearea around nodes page * fix rescan page layout * fix exception on really fast switching * remove broken blur * card customizer autosave * remove debug print * add better fallbacks for currency titles * revert due to broken animation * fix send page crash * fix chain title for arb * fix cupertino date picker * Update lib/new-ui/widgets/receive_page/receive_bottom_buttons.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * feat: add focus management and external address validation to send page forms - Introduced `focusNode` to `NewSendAddressInput` for better input handling. - Enhanced address validation by synchronizing with parsed external addresses. - Updated logic for non-MWEB unspent coin type in send actions. - Suppressed unnecessary exception logs in Bitcoin wallet transactions. * New design swap page fixes (#2923) * swap page fixes * add scroll controller * comment * tweak refresh pulldown (#2924) * add copy button to l2 send external modal (#2925) * account customizer padding * feat: lightning transaction fetching and Lightning wallet integration (#2927) - Allow nullable `height` in `ElectrumTransactionInfo`. - Add `fromDate` support for filtered Lightning transaction history retrieval. - Simplify Lightning address handling logic in wallet addresses. - Optimize Lightning wallet transaction syncing based on the last Lightning transaction date. - Clean up imports in `electrum_transaction_history.dart`. * New balance handeling (#2931) * feat: lightning transaction fetching and Lightning wallet integration - Allow nullable `height` in `ElectrumTransactionInfo`. - Add `fromDate` support for filtered Lightning transaction history retrieval. - Simplify Lightning address handling logic in wallet addresses. - Optimize Lightning wallet transaction syncing based on the last Lightning transaction date. - Clean up imports in `electrum_transaction_history.dart`. * feat: add support for Lightning balance in wallet snapshot and initialization * Disable Lightning switcher for hardware wallets (#2932) * fix: disable Lightning switcher for hardware wallets * fix: update wallet type check to use `isSoftwareWallet` for Lightning support * New design pre beta fixes 6 (#2929) * fix swaps from ln * prevent crash if ln balance isn't loaded yet * fix currency icons disappearing on swap confirm sheet * fix swap fiat validation * display ln at top on swap currency selector in btc wallets * update icon for card options * display default fiat and crypto at top of currency picker * fix fiat amount bar formatting * add modal scroll controller to provider logs * revert premature optimization (sizing issue) * New design pre beta fixes 7 (#2935) * fix swaps from ln * prevent crash if ln balance isn't loaded yet * fix currency icons disappearing on swap confirm sheet * fix swap fiat validation * display ln at top on swap currency selector in btc wallets * update icon for card options * display default fiat and crypto at top of currency picker * fix fiat amount bar formatting * add modal scroll controller to provider logs * revert premature optimization (sizing issue) * copyable trade id * disable swaptrade on ln * set isFixedRate properly * update color * display trocador provider on swap confirmation sheet * add "exchange rate is fixed" text --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * updated l2 modal (#2934) * display names for send addr input (#2936) * fix: MWEB toggle logic on send page (#2938) * feat: add retry logic to `getAddress` in Lightning wallet (#2939) * Enhance crypto address handling and add Lightning invoice support (#2937) * feat: enhance crypto address handling and add Lightning invoice support - Added `_overrideFromCryptoCurrency` and `_overrideToCryptoCurrency` for Zcash unified and shielded addresses. - Improved Lightning invoice generation with `getLightningInvoice` for Bitcoin wallets. - Updated error handling in exchange provider to accommodate API changes. - Introduced Lightning invoice fallback for deposit and receive addresses in ExchangeViewModel. * feat: Added `_overrideFromCryptoCurrency` and `_overrideToCryptoCurrency` for Zcash unified and shielded addresses. * fix pay anything on paste button (#2940) * Prevent multiple paste triggering any pay flow * fixup fiat input (#2941) * New design small fixes (#2920) * Fix optical symmetry for swipe to send text * Update nav bar icons * Top bar and card tweaks * Update paddings --------- Co-authored-by: malik1004x <malikowskirobert@gmail.com> * fix erc20 balance display (#2944) * fix erc20 balance display * route through cw_evm * New design beta fixes (#2943) * fix asset tile layout * fix card customizer keyboard jumping * fix cardsview exception * fix swap modal height * remove syncbar percentage * add copy icon to trade id * fix trade confirmation appearing twice * remove useless mweb setting * add tag to contact currency selector text * prettify picker for ln * fix receive crash * always route to NewSendPage * handle ln amount on paste * handle ln amount on payment request creation * prettify ln errors * readd "blocks" word * register deeplinks * Enhance bitcoin error message [skip ci] * fix support chat page (#2946) * new-design-fix-confirm-sheet-parsing-error (#2950) * feat: use bigint instead of doubles * feat: use bigint instead of doubles * feat: use bigint instead of doubles * fix: also show sats in confirm sheet * fix: also show sats in confirm sheet * feat: localize amounts and cap amount in tx history (#2951) * fix: linux CI * feat: localize token balances (#2954) * fix: send amount hww (#2955) * chore: use latest breez sdk (#2953) * fix addAddressWord * fixes (#2957) * receive fixes (#2959) * fix: stabilize android build by increasing jvm heap size (#2958) * fix: lighting by having the new SDK Save into a new location (#2961) * New design rc fixes (#2960) * additional safeguards for isSyncHeavy check * fix account name getting reset * update base icon * fix units in swap * readd memos to zec * New design minor UI (#2956) * Wrap text for list item widgets * Update lightning address and QR icons * Update near intents icon * Fix share issue * Fix (#2963) * fix tx amount formatting * rename currency * change wording for zec memo * fix base icon * fix app icon script [skip ci] * New design rc fixes 2 (#2965) * fix account name changes * fix spacing on addresses page * add payjoin copy modal * improve memo ui * potential fix for ci * Set default address for zcash and bitcoin for buy flow (#2979) * new monero.com icons (#2980) * parse and validate deposit amount from api (#2967) * generic fixes * minor context fix [skip ci] * Generic fixes (#2982) - solana send all bug - pasting SOL address triggering payanything flow - add more address types for payanything detection * rescan fix * about page (#2974) Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * update settings icons/wording (#2973) * Changelog modal (New UI) (#2971) * add new changelog modal * typo * print -> printV * Update lib/new-ui/widgets/changelog_modal.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * fix node form (#2970) * new-design-add-breez-logging (#2984) * feat: add Lightning log export functionality for Bitcoin wallets * feat: add multilingual support for Lightning log export strings * feat: add Lightning support toggle in settings and translations for multiple languages * refactor: simplify `setUseLightning` by removing redundant store update * Update cw_bitcoin/lib/electrum_wallet.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * minor fixes [skip ci] * minor context fixe [skip ci] * fix: make walletinfoid unique to prevent duplicates (#2969) * fix: walletconnect not working in new design builds (#2993) * new-design-fix-mweb-coin-enabling (#2995) * feat: add unspent coin type handling to asset details modal send button * fix: improve German translations for wallet, seed, and Lightning-related strings * fix: update Dutch translations to correct terminology and formatting #2992 (#2997) * fix: drop gn (#3000) * vulnerable seeds popup on new ui (#3004) * update mac os monero.com icons (#3003) * Add Payjoin log export and improve logging behavior (#2999) * fix: suppress exception logging in `getAddress` method of Lightning wallet - Added a try-catch block to avoid unnecessary exception logs during Lightning address retries. * fix: update fallback message for missing Lightning address detection * feat: add Payjoin log export and logging enhancements * fix: localize "Export Payjoin Logs" string in settings page * fix: litecoin mweb balance being included in the second asset (#2998) * Minor fixes (#2994) * Minor fixes * Update lib/new-ui/new_dashboard.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * New design post release fixes (#3002) * fix: only throw on deserialize if kDebugMode is true (#2976) This closes #2972, in debug mode we will still catch these issues but if somehow that happens on production it will fallback to safe default * fix: update docs and dockerfile (#2975) * fix: missing steps for linux build [skip ci] (#2985) * move balance to bigint * move balance to bigint * fix electrum issue * fix unconfirmed balance * fixes * Fix minor issue in Spanish translation (#2991) * Fix minor issue in French translation (#2987) * Fix minor issues in German translation (#2986) * update constructor calls in configure.dart * fixes * remove expnded * V6.0.1 Early Release Candidate --------- Co-authored-by: cyan <cyjan@mrcyjanek.net> Co-authored-by: Edwin den Boer <woordenboer@planet.nl> Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> * Swaps xyz swap enhancements (#2615) * refactor token cache and limit handling * Improve SwapsXYZ external send logic * Improve SwapsXYZ fixed-rate handling * disable fixedRate for SwapsXyz * SwapsXYZ contract call * Add track url for swaps xyz * add arbitrum support * add check for unsupported source tokens * enable SwapsXyzExchangeProvider in provider list * refactor SwapsXYZ provider and trade flow handling * Update exchange_trade_view_model.dart * validate evm call-data * Revert "validate evm call-data" * fix msg value for ERC-20 transfers * fix flag for swapsXYZ send check * Update send_view_model.dart * handle Swaps.xyz method selectors & approvals * fix evm approvals * Improve EVM token approval & receipt handling * merge split token transfers in evm tx * fix token allowance check for approvals * add sourceToken validation to EVM tx creation * prioritizing incoming transactions over fetched outgoing ones * compute net flow when merging transactions * add truncateTrailingText to list items and widgets --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> Co-authored-by: Serhii-Borodenko <17529954+Serhii-Borodenko@users.noreply.github.com> * fix wownero balance (#3007) * fix keyboard (#3006) * fix android build * check if stream is closed [skip ci] * [skip ci] lint * fix: populate amount field (#3009) * fix address rotation exception (#3011) * copy uri with amount from recieve page (#3010) * add "transaction sent!" to swap confirmation sheet (#3012) * fix wallet change on token swaps (#3013) * Fix fee estimation and recipient logic in Lightning Network (#3014) * fix: update `hasMultiRecipient` logic to include non-Lightning coin type check * fix: Lightning Network fee estimation and parsing logic * fix: adjust `sumByBigInt` logic to handle `sendAll` flag in send page * fix: move sqlite migrations to sqlite.dart (#3008) * fix: move sqlite migrations to sqlite.dart fix: backup restore not initializing SQL properly * Update cw_core/lib/db/sqlite.dart --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * feat: update currency symbol handling and extend Electrum transaction details (#3016) * Use isCentralized for truncation trade id [skip ci] * fix: Incorrect token amount for tokens and filter out new spam transactions after swaps (#3015) * New design release swap fixes (#3018) * fix deserialize ln * fix get wallet type for bnb tokens * show extraId for swaps * chore: translate using gpt-5.2 (#3021) * add NEAR send-all validation * tiny ui fixes (#3023) * use double parsing for amount comparison[skip ci] * adjust lightning address error message * feat: add BTC LN support to available methods and payment data handling * feat: add cached Lightning address handling for improved performance (#3025) - Introduced `cachedAddress` field to store and reuse the last fetched Lightning address. - Updated `getLightningAddress` method to fallback on `cachedAddress` if no new address is fetched. - Extended wallet constructors and snapshots to include `cachedLightningAddress` for persistence. * Revert transaction history color * Minor * Apply suggestion from @malik1004x * new-design-post-release-fixes-3 (#3028) * fix unnecessary account switching * fix exception on bad payment amount * fallback for currencies on external swap modal * increase balance card touch target * don't use lightning addresses for exchange * increase max length for ln encoding * don't show infobox on ln receive * fix showing old tx details (null tx on createTransaction) * remove unused import * refactor: relocate `_logStream` declaration in `LightningWallet` for better code organization (#3029) * monero build fix update build numbers fix best rate null [skip ci] * hide swap on mweb asset * minor context fix [skip ci] * Fix Silent payment case * new-ui: fix changelog typo (#3036) Fix typo in changelog for account management. * Modify date format to Month DD YYYY * feat: docker based ci * Fix 2FA continue button location (#3043) * fix: Desktop wallet bugs (#2968) * fix: Desktop wallet bugs - repeated wallets post migration - newly created wallets not showing up - extra large components on desktop, needed maxwidth * chore: Remove duplicate logic * chore: remove formatting * refactor: streamline updateList method and handle multiple calls with a future based mutex * refactor: enhance swipe to confirm with dynamic width handling and improved drag threshold logic * Improve error handling and duplicate invoice handling in Lightning wallet (#3047) * fix: handle duplicate Lightning invoice payments gracefully * fix: improved error handling in Lightning wallet * General improvements (#3030) * General Improvements - Make borderRadius for CTAs uniform 18px - Identify hardware wallets in title of Seeds/Keys page - Make entire wallet tile clickable in wallet list * chore: Simplify check * Update lib/view_model/wallet_keys_view_model.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * homescreen improvements (#3034) * Homescreen improvements - Increase touch area for card editing icon - Tapping any card in the background should move it ino the foreground without closing the account tab - make top left chain icon primary color with full opacity when syncing and 20% when done - add tor indicator to top bar when enabled * fix: remove unneeded color filter * refactor: Adjust structure for tor and sync indicators * minor fixes (#3045) * Enhance LNURL payment integration (#3041) * feat: enhance LNURL support and Lightning payment handling - Improve LNURL decoding and encoding with expanded prefix handling. - Add support for parsing and validating LNURL payment invoices. - Introduce logic for fetching LNURL payment request amounts. - Update payment flow to integrate LNURL and Lightning-specific conditions. - Refactor BOLT11 prefix validation and amount extraction logic. * fix: simplify LNURL invoice validation by removing redundant BOLT11 check --------- Signed-off-by: black5box <black5box@outlook.com> Co-authored-by: Serhii <borodenko.sv@gmail.com> Co-authored-by: malik1004x <malikowskirobert@gmail.com> Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: black5box <black5box@outlook.com> Co-authored-by: cyan <cyjan@mrcyjanek.net> Co-authored-by: David Adegoke <64401859+Blazebrain@users.noreply.github.com> Co-authored-by: Konstantin Ullrich <konstantin@cakewallet.com> Co-authored-by: Edwin den Boer <woordenboer@planet.nl> Co-authored-by: Serhii <17529954+serhii-bor@users.noreply.github.com> Co-authored-by: Serhii-Borodenko <17529954+Serhii-Borodenko@users.noreply.github.com> Co-authored-by: rottenwheel <92872541+rottenwheel@users.noreply.github.com>
2057 lines
76 KiB
Dart
2057 lines
76 KiB
Dart
import 'dart:io';
|
|
|
|
const bitcoinOutputPath = 'lib/bitcoin/bitcoin.dart';
|
|
const moneroOutputPath = 'lib/monero/monero.dart';
|
|
const bitcoinCashOutputPath = 'lib/bitcoin_cash/bitcoin_cash.dart';
|
|
const nanoOutputPath = 'lib/nano/nano.dart';
|
|
const solanaOutputPath = 'lib/solana/solana.dart';
|
|
const tronOutputPath = 'lib/tron/tron.dart';
|
|
const wowneroOutputPath = 'lib/wownero/wownero.dart';
|
|
const zanoOutputPath = 'lib/zano/zano.dart';
|
|
const decredOutputPath = 'lib/decred/decred.dart';
|
|
const dogecoinOutputPath = 'lib/dogecoin/dogecoin.dart';
|
|
const evmOutputPath = 'lib/evm/evm.dart';
|
|
const zcashOutputPath = 'lib/zcash/zcash.dart';
|
|
const walletTypesPath = 'lib/wallet_types.g.dart';
|
|
const secureStoragePath = 'lib/core/secure_storage.dart';
|
|
const pubspecDefaultPath = 'pubspec_default.yaml';
|
|
const pubspecOutputPath = 'pubspec.yaml';
|
|
|
|
Future<void> main(List<String> args) async {
|
|
const prefix = '--';
|
|
final hasBitcoin = args.contains('${prefix}bitcoin');
|
|
final hasMonero = args.contains('${prefix}monero');
|
|
final hasEthereum = args.contains('${prefix}ethereum');
|
|
final hasBitcoinCash = args.contains('${prefix}bitcoinCash');
|
|
final hasNano = args.contains('${prefix}nano');
|
|
final hasBanano = args.contains('${prefix}banano');
|
|
final hasPolygon = args.contains('${prefix}polygon');
|
|
final hasSolana = args.contains('${prefix}solana');
|
|
final hasTron = args.contains('${prefix}tron');
|
|
final hasWownero = args.contains('${prefix}wownero');
|
|
final hasZano = args.contains('${prefix}zano');
|
|
final hasDecred = args.contains('${prefix}decred');
|
|
final hasDogecoin = args.contains('${prefix}dogecoin');
|
|
final hasBase = args.contains('${prefix}base');
|
|
final hasArbitrum = args.contains('${prefix}arbitrum');
|
|
final hasBsc = args.contains('${prefix}bsc');
|
|
final hasZcash = args.contains('${prefix}zcash');
|
|
final hasEVM = hasEthereum || hasPolygon || hasBase || hasArbitrum || hasBsc;
|
|
final excludeFlutterSecureStorage = args.contains('${prefix}excludeFlutterSecureStorage');
|
|
|
|
await generateBitcoin(hasBitcoin);
|
|
await generateMonero(hasMonero);
|
|
await generateBitcoinCash(hasBitcoinCash);
|
|
await generateNano(hasNano);
|
|
await generateSolana(hasSolana);
|
|
await generateTron(hasTron);
|
|
await generateWownero(hasWownero);
|
|
await generateZano(hasZano);
|
|
// await generateBanano(hasEthereum);
|
|
await generateDecred(hasDecred);
|
|
await generateDogecoin(hasDogecoin);
|
|
await generateEVM(hasEVM);
|
|
await generateZcash(hasZcash);
|
|
|
|
await generatePubspec(
|
|
hasMonero: hasMonero,
|
|
hasBitcoin: hasBitcoin,
|
|
hasEthereum: hasEthereum,
|
|
hasNano: hasNano,
|
|
hasBanano: hasBanano,
|
|
hasBitcoinCash: hasBitcoinCash,
|
|
hasFlutterSecureStorage: !excludeFlutterSecureStorage,
|
|
hasPolygon: hasPolygon,
|
|
hasSolana: hasSolana,
|
|
hasTron: hasTron,
|
|
hasWownero: hasWownero,
|
|
hasZano: hasZano,
|
|
hasDecred: hasDecred,
|
|
hasDogecoin: hasDogecoin,
|
|
hasBase: hasBase,
|
|
hasArbitrum: hasArbitrum,
|
|
hasBsc: hasBsc,
|
|
hasZcash: hasZcash,
|
|
);
|
|
await generateWalletTypes(
|
|
hasMonero: hasMonero,
|
|
hasBitcoin: hasBitcoin,
|
|
hasEthereum: hasEthereum,
|
|
hasNano: hasNano,
|
|
hasBanano: hasBanano,
|
|
hasBitcoinCash: hasBitcoinCash,
|
|
hasPolygon: hasPolygon,
|
|
hasSolana: hasSolana,
|
|
hasTron: hasTron,
|
|
hasWownero: hasWownero,
|
|
hasZano: hasZano,
|
|
hasDecred: hasDecred,
|
|
hasDogecoin: hasDogecoin,
|
|
hasBase: hasBase,
|
|
hasArbitrum: hasArbitrum,
|
|
hasBsc: hasBsc,
|
|
hasZcash: hasZcash,
|
|
);
|
|
await injectSecureStorage(!excludeFlutterSecureStorage);
|
|
}
|
|
|
|
Future<void> generateBitcoin(bool hasImplementation) async {
|
|
final outputFile = File(bitcoinOutputPath);
|
|
const bitcoinCommonHeaders = """
|
|
import 'dart:io' show Platform;
|
|
import 'dart:typed_data';
|
|
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cw_core/hardware/hardware_account_data.dart';
|
|
import 'package:cw_core/hardware/hardware_wallet_service.dart';
|
|
import 'package:cw_core/node.dart';
|
|
import 'package:cw_core/payjoin_session.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
import 'package:cw_core/receive_page_option.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/unspent_coin_type.dart';
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
import 'package:cw_core/unspent_transaction_output.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:cw_core/get_height_by_date.dart';
|
|
import 'package:hive/hive.dart';
|
|
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
|
|
import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
|
|
import 'package:trezor_connect/trezor_connect.dart' as trezor;
|
|
import 'package:blockchain_utils/blockchain_utils.dart';
|
|
import 'package:bip39/bip39.dart' as bip39;
|
|
""";
|
|
const bitcoinCWHeaders = """
|
|
import 'package:cw_bitcoin/utils.dart';
|
|
import 'package:cw_bitcoin/electrum_derivations.dart';
|
|
import 'package:cw_bitcoin/electrum.dart';
|
|
import 'package:cw_bitcoin/electrum_transaction_info.dart';
|
|
import 'package:cw_bitcoin/pending_bitcoin_transaction.dart';
|
|
import 'package:cw_bitcoin/bitcoin_receive_page_option.dart';
|
|
import 'package:cw_bitcoin/electrum_wallet.dart';
|
|
import 'package:cw_bitcoin/bitcoin_unspent.dart';
|
|
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
|
import 'package:cw_bitcoin/bitcoin_transaction_priority.dart';
|
|
import 'package:cw_bitcoin/bitcoin_wallet.dart';
|
|
import 'package:cw_bitcoin/bitcoin_wallet_service.dart';
|
|
import 'package:cw_bitcoin/bitcoin_wallet_creation_credentials.dart';
|
|
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
|
import 'package:cw_bitcoin/bitcoin_wallet_addresses.dart';
|
|
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
|
|
import 'package:cw_bitcoin/lightning/pending_lightning_transaction.dart';
|
|
import 'package:cw_bitcoin/litecoin_wallet_service.dart';
|
|
import 'package:cw_bitcoin/litecoin_wallet.dart';
|
|
import 'package:cw_bitcoin/hardware/bitcoin_ledger_service.dart';
|
|
import 'package:cw_bitcoin/hardware/litecoin_ledger_service.dart';
|
|
import 'package:cw_bitcoin/hardware/bitbox_service.dart';
|
|
import 'package:cw_bitcoin/hardware/trezor_service.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import "package:breez_sdk_spark_flutter/src/rust/errors.dart";
|
|
""";
|
|
const bitcoinCwPart = "part 'cw_bitcoin.dart';";
|
|
const bitcoinContent = """
|
|
|
|
class ElectrumSubAddress {
|
|
ElectrumSubAddress({
|
|
required this.id,
|
|
required this.name,
|
|
required this.address,
|
|
required this.txCount,
|
|
required this.balance,
|
|
required this.isChange});
|
|
final int id;
|
|
final String name;
|
|
final String address;
|
|
final int txCount;
|
|
final int balance;
|
|
final bool isChange;
|
|
}
|
|
|
|
abstract class Bitcoin {
|
|
TransactionPriority getMediumTransactionPriority();
|
|
|
|
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials({
|
|
required String name,
|
|
required String mnemonic,
|
|
required String password,
|
|
required DerivationType derivationType,
|
|
required String derivationPath,
|
|
String? passphrase,
|
|
});
|
|
WalletCredentials createBitcoinRestoreWalletFromWIFCredentials({required String name, required String password, required String wif, WalletInfo? walletInfo});
|
|
WalletCredentials createBitcoinWalletFromKeys({required String name, required String password, required String xpub, HardwareWalletType? hardwareWalletType});
|
|
WalletCredentials createLitecoinWalletFromKeys({required String name, required String password, required String xpub, required String scanSecret, required String spendPubkey});
|
|
WalletCredentials createBitcoinNewWalletCredentials({required String name, WalletInfo? walletInfo, String? password, String? passphrase, String? mnemonic});
|
|
WalletCredentials createBitcoinHardwareWalletCredentials({required String name, required HardwareAccountData accountData, WalletInfo? walletInfo});
|
|
List<String> getWordList();
|
|
Map<String, String> getWalletKeys(Object wallet);
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
List<TransactionPriority> getLitecoinTransactionPriorities();
|
|
TransactionPriority deserializeBitcoinTransactionPriority(int raw);
|
|
TransactionPriority deserializeLitecoinTransactionPriority(int raw);
|
|
int getFeeRate(Object wallet, TransactionPriority priority);
|
|
Future<void> generateNewAddress(Object wallet, String label);
|
|
Future<void> updateAddress(Object wallet,String address, String label);
|
|
Object createBitcoinTransactionCredentials(List<Output> outputs, {required TransactionPriority priority, int? feeRate, UnspentCoinType coinTypeToSpendFrom = UnspentCoinType.any, String? payjoinUri});
|
|
|
|
String getAddress(Object wallet);
|
|
List<ElectrumSubAddress> getSilentPaymentAddresses(Object wallet);
|
|
List<ElectrumSubAddress> getSilentPaymentReceivedAddresses(Object wallet);
|
|
|
|
Future<int> estimateFakeSendAllTxAmount(Object wallet, TransactionPriority priority,
|
|
{UnspentCoinType coinTypeToSpendFrom = UnspentCoinType.any});
|
|
List<ElectrumSubAddress> getSubAddresses(Object wallet);
|
|
|
|
String formatterBitcoinAmountToString({required int amount});
|
|
double formatterBitcoinAmountToDouble({required int amount});
|
|
int formatterStringDoubleToBitcoinAmount(String amount);
|
|
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate, {int? customRate});
|
|
|
|
List<Unspent> getUnspents(Object wallet, {UnspentCoinType coinTypeToSpendFrom = UnspentCoinType.any});
|
|
Future<void> updateUnspents(Object wallet);
|
|
WalletService createBitcoinWalletService(
|
|
Box<UnspentCoinsInfo> unspentCoinSource, Box<PayjoinSession> payjoinSessionSource, bool isDirect);
|
|
WalletService createLitecoinWalletService(Box<UnspentCoinsInfo> unspentCoinSource, bool isDirect);
|
|
TransactionPriority getBitcoinTransactionPriorityMedium();
|
|
TransactionPriority getBitcoinTransactionPriorityCustom();
|
|
TransactionPriority getLitecoinTransactionPriorityMedium();
|
|
TransactionPriority getBitcoinTransactionPrioritySlow();
|
|
TransactionPriority getLitecoinTransactionPrioritySlow();
|
|
Future<List<DerivationType>> compareDerivationMethods(
|
|
{required String mnemonic, required Node node});
|
|
Future<List<DerivationInfo>> getDerivationsFromMnemonic(
|
|
{required String mnemonic, required Node node, String? passphrase});
|
|
Map<DerivationType, List<DerivationInfo>> getElectrumDerivations();
|
|
Future<void> setAddressType(Object wallet, dynamic option);
|
|
ReceivePageOption getSelectedAddressType(Object wallet);
|
|
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option);
|
|
ReceivePageOption getBitcoinLightningReceivePageOption();
|
|
ReceivePageOption getBitcoinSegwitPageOption();
|
|
ReceivePageOption getLitecoinMwebReceivePageOption();
|
|
bool isPayjoinAvailable(Object wallet);
|
|
bool hasSelectedSilentPayments(Object wallet);
|
|
bool isBitcoinReceivePageOption(ReceivePageOption option);
|
|
BitcoinAddressType getOptionToType(ReceivePageOption option);
|
|
bool hasTaprootInput(PendingTransaction pendingTransaction);
|
|
bool getScanningActive(Object wallet);
|
|
Future<void> setScanningActive(Object wallet, bool active);
|
|
Future<void> setIsAlwaysScanningSP(Object wallet, bool active);
|
|
bool getIsAlwaysScanningSP(Object wallet);
|
|
bool isTestnet(Object wallet);
|
|
|
|
Future<PendingTransaction> replaceByFee(Object wallet, String transactionHash, String fee);
|
|
Future<String?> canReplaceByFee(Object wallet, Object tx);
|
|
int getTransactionVSize(Object wallet, String txHex);
|
|
Future<bool> isChangeSufficientForFee(Object wallet, String txId, String newFee);
|
|
int getFeeAmountForPriority(Object wallet, TransactionPriority priority, int inputsCount, int outputsCount, {int? size});
|
|
int getEstimatedFeeWithFeeRate(Object wallet, int feeRate, int? amount,
|
|
{int? outputsCount, int? size});
|
|
int feeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount, {int? size});
|
|
Future<bool> checkIfMempoolAPIIsEnabled(Object wallet);
|
|
Future<int> getHeightByDate({required DateTime date, bool? bitcoinMempoolAPIEnabled});
|
|
int getLitecoinHeightByDate({required DateTime date});
|
|
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
|
|
Future<bool> getNodeIsElectrsSPEnabled(Object wallet);
|
|
void deleteSilentPaymentAddress(Object wallet, String address);
|
|
Future<void> updateFeeRates(Object wallet);
|
|
int getMaxCustomFeeRate(Object wallet);
|
|
Future<void> setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
|
|
HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection, bool isBitcoin);
|
|
HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager, bool isBitcoin);
|
|
HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect, bool isBitcoin);
|
|
List<Output> updateOutputs(PendingTransaction pendingTransaction, List<Output> outputs);
|
|
bool txIsReceivedSilentPayment(TransactionInfo txInfo);
|
|
bool txIsMweb(TransactionInfo txInfo);
|
|
Future<void> setMwebEnabled(Object wallet, bool enabled);
|
|
bool getMwebEnabled(Object wallet);
|
|
String? getUnusedMwebAddress(Object wallet);
|
|
String? getUnusedSegwitAddress(Object wallet);
|
|
Future<String?> getUnusedSpakDepositAddress(Object wallet);
|
|
Future<void> commitPsbtUR(Object wallet, List<String> urCodes);
|
|
|
|
void updatePayjoinState(Object wallet, bool state);
|
|
String getPayjoinEndpoint(Object wallet);
|
|
void resumePayjoinSessions(Object wallet);
|
|
void stopPayjoinSessions(Object wallet);
|
|
Map<String, String> getSilentPaymentKeys(Object wallet);
|
|
List<String>? getTransactionAddresses(Object wallet, TransactionInfo tx);
|
|
String getNetworkName(Object wallet);
|
|
bool useLightning(Object wallet);
|
|
void updateUseLightning(Object wallet, bool value);
|
|
Future<void> setLightningUsername(Object wallet, String username);
|
|
Future<String?> getLightningUsername(Object wallet);
|
|
Future<String?> getLightningInvoice(Object wallet, BigInt amount);
|
|
String? getBreezSdkError(Object exception);
|
|
}
|
|
""";
|
|
|
|
const bitcoinEmptyDefinition = 'Bitcoin? bitcoin;\n';
|
|
const bitcoinCWDefinition = 'Bitcoin? bitcoin = CWBitcoin();\n';
|
|
|
|
final output = '$bitcoinCommonHeaders\n' +
|
|
(hasImplementation ? '$bitcoinCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$bitcoinCwPart\n\n' : '\n') +
|
|
(hasImplementation ? bitcoinCWDefinition : bitcoinEmptyDefinition) +
|
|
'\n' +
|
|
bitcoinContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateMonero(bool hasImplementation) async {
|
|
final outputFile = File(moneroOutputPath);
|
|
const moneroCommonHeaders = """
|
|
import 'package:cw_core/unspent_transaction_output.dart';
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:hive/hive.dart';
|
|
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
|
|
import 'package:polyseed/polyseed.dart';""";
|
|
const moneroCWHeaders = """
|
|
import 'package:cw_core/account.dart' as monero_account;
|
|
import 'package:cw_core/get_height_by_date.dart';
|
|
import 'package:cw_core/monero_amount_format.dart';
|
|
import 'package:cw_core/monero_transaction_priority.dart';
|
|
import 'package:cw_monero/api/wallet_manager.dart';
|
|
import 'package:cw_monero/api/wallet.dart' as monero_wallet_api;
|
|
import 'package:cw_monero/ledger.dart';
|
|
import 'package:cw_monero/monero_unspent.dart';
|
|
import 'package:cw_monero/api/account_list.dart';
|
|
import 'package:cw_monero/monero_wallet_service.dart';
|
|
import 'package:cw_monero/monero_wallet.dart';
|
|
import 'package:cw_monero/monero_transaction_info.dart';
|
|
import 'package:cw_monero/monero_transaction_creation_credentials.dart';
|
|
import 'package:cw_monero/mnemonics/english.dart';
|
|
import 'package:cw_monero/mnemonics/chinese_simplified.dart';
|
|
import 'package:cw_monero/mnemonics/dutch.dart';
|
|
import 'package:cw_monero/mnemonics/german.dart';
|
|
import 'package:cw_monero/mnemonics/japanese.dart';
|
|
import 'package:cw_monero/mnemonics/russian.dart';
|
|
import 'package:cw_monero/mnemonics/spanish.dart';
|
|
import 'package:cw_monero/mnemonics/portuguese.dart';
|
|
import 'package:cw_monero/mnemonics/french.dart';
|
|
import 'package:cw_monero/mnemonics/italian.dart';
|
|
import 'package:cw_monero/pending_monero_transaction.dart';
|
|
""";
|
|
const moneroCwPart = "part 'cw_monero.dart';";
|
|
const moneroContent = """
|
|
class Account {
|
|
Account({required this.id, required this.label, this.balance});
|
|
final int id;
|
|
final String label;
|
|
final String? balance;
|
|
}
|
|
|
|
class Subaddress {
|
|
Subaddress({
|
|
required this.id,
|
|
required this.label,
|
|
required this.address,
|
|
required this.received,
|
|
required this.txCount});
|
|
final int id;
|
|
final String label;
|
|
final String address;
|
|
final String? received;
|
|
final int txCount;
|
|
}
|
|
|
|
class MoneroBalance extends Balance {
|
|
MoneroBalance({required this.fullBalance, required this.unlockedBalance})
|
|
: formattedFullBalance = monero!.formatterMoneroAmountToString(amount: fullBalance),
|
|
formattedUnlockedBalance =
|
|
monero!.formatterMoneroAmountToString(amount: unlockedBalance),
|
|
super.fromInt(unlockedBalance, fullBalance);
|
|
|
|
MoneroBalance.fromString(
|
|
{required this.formattedFullBalance,
|
|
required this.formattedUnlockedBalance})
|
|
: fullBalance = monero!.formatterMoneroParseAmount(amount: formattedFullBalance),
|
|
unlockedBalance = monero!.formatterMoneroParseAmount(amount: formattedUnlockedBalance),
|
|
super.fromInt(monero!.formatterMoneroParseAmount(amount: formattedUnlockedBalance),
|
|
monero!.formatterMoneroParseAmount(amount: formattedFullBalance));
|
|
|
|
final int fullBalance;
|
|
final int unlockedBalance;
|
|
final String formattedFullBalance;
|
|
final String formattedUnlockedBalance;
|
|
|
|
@override
|
|
String get formattedAvailableBalance => formattedUnlockedBalance;
|
|
|
|
@override
|
|
String get formattedAdditionalBalance => formattedFullBalance;
|
|
}
|
|
|
|
abstract class MoneroWalletDetails {
|
|
@observable
|
|
late Account account;
|
|
|
|
@observable
|
|
late MoneroBalance balance;
|
|
}
|
|
|
|
abstract class Monero {
|
|
MoneroAccountList getAccountList(Object wallet);
|
|
|
|
MoneroSubaddressList getSubaddressList(Object wallet);
|
|
|
|
TransactionHistoryBase getTransactionHistory(Object wallet);
|
|
|
|
MoneroWalletDetails getMoneroWalletDetails(Object wallet);
|
|
|
|
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
|
|
|
|
String getSubaddressLabel(Object wallet, int accountIndex, int addressIndex);
|
|
|
|
int getHeightByDate({required DateTime date});
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
TransactionPriority getMoneroTransactionPrioritySlow();
|
|
TransactionPriority getMoneroTransactionPriorityAutomatic();
|
|
TransactionPriority deserializeMoneroTransactionPriority({required int raw});
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
List<String> getMoneroWordList(String language);
|
|
|
|
List<Unspent> getUnspents(Object wallet);
|
|
Future<void> updateUnspents(Object wallet);
|
|
|
|
Future<int> getCurrentHeight();
|
|
|
|
Future<bool> commitTransactionUR(Object wallet, String ur);
|
|
|
|
Map<String, String> exportOutputsUR(Object wallet);
|
|
|
|
bool needExportOutputs(Object wallet, int amount);
|
|
|
|
bool importKeyImagesUR(Object wallet, String ur);
|
|
|
|
WalletCredentials createMoneroRestoreWalletFromKeysCredentials({
|
|
required String name,
|
|
required String spendKey,
|
|
required String viewKey,
|
|
required String address,
|
|
required String password,
|
|
required String language,
|
|
required int height});
|
|
WalletCredentials createMoneroRestoreWalletFromSeedCredentials({required String name, required String password, required String passphrase, required int height, required String mnemonic});
|
|
WalletCredentials createMoneroRestoreWalletFromHardwareCredentials({required String name, required String password, required int height, required ledger.LedgerConnection ledgerConnection});
|
|
WalletCredentials createMoneroNewWalletCredentials({required String name, required String language, required int seedType, required String? passphrase, String? password, String? mnemonic});
|
|
Map<String, String> getKeys(Object wallet);
|
|
int? getRestoreHeight(Object wallet);
|
|
Object createMoneroTransactionCreationCredentials({required List<Output> outputs, required TransactionPriority priority});
|
|
Object createMoneroTransactionCreationCredentialsRaw({required List<OutputInfo> outputs, required TransactionPriority priority});
|
|
String formatterMoneroAmountToString({required int amount});
|
|
double formatterMoneroAmountToDouble({required int amount});
|
|
int formatterMoneroParseAmount({required String amount});
|
|
Account getCurrentAccount(Object wallet);
|
|
void monerocCheck();
|
|
bool isViewOnly();
|
|
void setCurrentAccount(Object wallet, int id, String label, String? balance);
|
|
void onStartup();
|
|
int getTransactionInfoAccountId(TransactionInfo tx);
|
|
WalletService createMoneroWalletService(Box<UnspentCoinsInfo> unspentCoinSource);
|
|
Map<String, String> pendingTransactionInfo(Object transaction);
|
|
Future<void> setLedgerConnection(Object wallet, ledger.LedgerConnection connection);
|
|
void resetLedgerConnection();
|
|
void setGlobalLedgerConnection(ledger.LedgerConnection connection);
|
|
String? getLastLedgerCommand();
|
|
Map<String, List<int>> debugCallLength();
|
|
Map<String, dynamic> getWalletCacheDebug();
|
|
}
|
|
|
|
abstract class MoneroSubaddressList {
|
|
ObservableList<Subaddress> get subaddresses;
|
|
void update(Object wallet, {required int accountIndex});
|
|
void refresh(Object wallet, {required int accountIndex});
|
|
List<Subaddress> getAll(Object wallet);
|
|
Future<void> addSubaddress(Object wallet, {required int accountIndex, required String label});
|
|
Future<void> setLabelSubaddress(Object wallet,
|
|
{required int accountIndex, required int addressIndex, required String label});
|
|
}
|
|
|
|
abstract class MoneroAccountList {
|
|
ObservableList<Account> get accounts;
|
|
void update(Object wallet);
|
|
void refresh(Object wallet);
|
|
List<Account> getAll(Object wallet);
|
|
Future<void> addAccount(Object wallet, {required String label});
|
|
Future<void> setLabelAccount(Object wallet, {required int accountIndex, required String label});
|
|
}
|
|
""";
|
|
|
|
const moneroEmptyDefinition = 'Monero? monero;\n';
|
|
const moneroCWDefinition = 'Monero? monero = CWMonero();\n';
|
|
|
|
final output = '$moneroCommonHeaders\n' +
|
|
(hasImplementation ? '$moneroCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$moneroCwPart\n\n' : '\n') +
|
|
(hasImplementation ? moneroCWDefinition : moneroEmptyDefinition) +
|
|
'\n' +
|
|
moneroContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateWownero(bool hasImplementation) async {
|
|
final outputFile = File(wowneroOutputPath);
|
|
const wowneroCommonHeaders = """
|
|
import 'package:cw_core/unspent_transaction_output.dart';
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cake_wallet/core/key_service.dart';
|
|
import 'package:cake_wallet/core/secure_storage.dart';
|
|
import 'package:cake_wallet/entities/haven_seed_store.dart';
|
|
import 'package:cw_core/cake_hive.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:hive/hive.dart';
|
|
import 'package:polyseed/polyseed.dart';""";
|
|
const wowneroCWHeaders = """
|
|
import 'package:cw_core/get_height_by_date.dart';
|
|
import 'package:cw_core/wownero_amount_format.dart';
|
|
import 'package:cw_core/monero_transaction_priority.dart';
|
|
import 'package:cw_wownero/wownero_unspent.dart';
|
|
import 'package:cw_wownero/wownero_wallet_service.dart';
|
|
import 'package:cw_wownero/wownero_wallet.dart';
|
|
import 'package:cw_wownero/wownero_transaction_info.dart';
|
|
import 'package:cw_wownero/wownero_transaction_creation_credentials.dart';
|
|
import 'package:cw_core/account.dart' as wownero_account;
|
|
import 'package:cw_wownero/api/wallet.dart' as wownero_wallet_api;
|
|
import 'package:cw_wownero/api/wallet_manager.dart';
|
|
import 'package:cw_wownero/mnemonics/english.dart';
|
|
import 'package:cw_wownero/mnemonics/chinese_simplified.dart';
|
|
import 'package:cw_wownero/mnemonics/dutch.dart';
|
|
import 'package:cw_wownero/mnemonics/german.dart';
|
|
import 'package:cw_wownero/mnemonics/japanese.dart';
|
|
import 'package:cw_wownero/mnemonics/russian.dart';
|
|
import 'package:cw_wownero/mnemonics/spanish.dart';
|
|
import 'package:cw_wownero/mnemonics/portuguese.dart';
|
|
import 'package:cw_wownero/mnemonics/french.dart';
|
|
import 'package:cw_wownero/mnemonics/italian.dart';
|
|
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
|
""";
|
|
const wowneroCwPart = "part 'cw_wownero.dart';";
|
|
const wowneroContent = """
|
|
class Account {
|
|
Account({required this.id, required this.label, this.balance});
|
|
final int id;
|
|
final String label;
|
|
final String? balance;
|
|
}
|
|
|
|
class Subaddress {
|
|
Subaddress({
|
|
required this.id,
|
|
required this.label,
|
|
required this.address});
|
|
final int id;
|
|
final String label;
|
|
final String address;
|
|
}
|
|
|
|
class WowneroBalance extends Balance {
|
|
WowneroBalance({required this.fullBalance, required this.unlockedBalance})
|
|
: formattedFullBalance = wownero!.formatterWowneroAmountToString(amount: fullBalance),
|
|
formattedUnlockedBalance =
|
|
wownero!.formatterWowneroAmountToString(amount: unlockedBalance),
|
|
super.fromInt(unlockedBalance, fullBalance);
|
|
|
|
WowneroBalance.fromString(
|
|
{required this.formattedFullBalance,
|
|
required this.formattedUnlockedBalance})
|
|
: fullBalance = wownero!.formatterWowneroParseAmount(amount: formattedFullBalance),
|
|
unlockedBalance = wownero!.formatterWowneroParseAmount(amount: formattedUnlockedBalance),
|
|
super.fromInt(wownero!.formatterWowneroParseAmount(amount: formattedUnlockedBalance),
|
|
wownero!.formatterWowneroParseAmount(amount: formattedFullBalance));
|
|
|
|
final int fullBalance;
|
|
final int unlockedBalance;
|
|
final String formattedFullBalance;
|
|
final String formattedUnlockedBalance;
|
|
|
|
@override
|
|
String get formattedAvailableBalance => formattedUnlockedBalance;
|
|
|
|
@override
|
|
String get formattedAdditionalBalance => formattedFullBalance;
|
|
}
|
|
|
|
abstract class WowneroWalletDetails {
|
|
@observable
|
|
late Account account;
|
|
|
|
@observable
|
|
late WowneroBalance balance;
|
|
}
|
|
|
|
abstract class Wownero {
|
|
WowneroAccountList getAccountList(Object wallet);
|
|
|
|
WowneroSubaddressList getSubaddressList(Object wallet);
|
|
|
|
TransactionHistoryBase getTransactionHistory(Object wallet);
|
|
|
|
WowneroWalletDetails getWowneroWalletDetails(Object wallet);
|
|
|
|
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
|
|
|
|
String getSubaddressLabel(Object wallet, int accountIndex, int addressIndex);
|
|
|
|
int getHeightByDate({required DateTime date});
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
TransactionPriority getWowneroTransactionPrioritySlow();
|
|
TransactionPriority getWowneroTransactionPriorityAutomatic();
|
|
TransactionPriority deserializeWowneroTransactionPriority({required int raw});
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
List<String> getWowneroWordList(String language);
|
|
|
|
List<Unspent> getUnspents(Object wallet);
|
|
Future<void> updateUnspents(Object wallet);
|
|
|
|
Future<int> getCurrentHeight();
|
|
void wownerocCheck();
|
|
|
|
WalletCredentials createWowneroRestoreWalletFromKeysCredentials({
|
|
required String name,
|
|
required String spendKey,
|
|
required String viewKey,
|
|
required String address,
|
|
required String password,
|
|
required String language,
|
|
required int height});
|
|
WalletCredentials createWowneroRestoreWalletFromSeedCredentials({required String name, required String password, required String passphrase, required int height, required String mnemonic});
|
|
WalletCredentials createWowneroNewWalletCredentials({required String name, required String language, required bool isPolyseed, String? password, String? passphrase});
|
|
int? getRestoreHeight(Object wallet);
|
|
Map<String, String> getKeys(Object wallet);
|
|
Object createWowneroTransactionCreationCredentials({required List<Output> outputs, required TransactionPriority priority});
|
|
Object createWowneroTransactionCreationCredentialsRaw({required List<OutputInfo> outputs, required TransactionPriority priority});
|
|
String formatterWowneroAmountToString({required int amount});
|
|
double formatterWowneroAmountToDouble({required int amount});
|
|
int formatterWowneroParseAmount({required String amount});
|
|
Account getCurrentAccount(Object wallet);
|
|
void setCurrentAccount(Object wallet, int id, String label, String? balance);
|
|
void onStartup();
|
|
int getTransactionInfoAccountId(TransactionInfo tx);
|
|
WalletService createWowneroWalletService(Box<UnspentCoinsInfo> unspentCoinSource);
|
|
Map<String, String> pendingTransactionInfo(Object transaction);
|
|
String getLegacySeed(Object wallet, String langName);
|
|
Map<String, List<int>> debugCallLength();
|
|
Future<void> backupSeeds(Box<HavenSeedStore> havenSeedStore);
|
|
}
|
|
|
|
abstract class WowneroSubaddressList {
|
|
ObservableList<Subaddress> get subaddresses;
|
|
void update(Object wallet, {required int accountIndex});
|
|
void refresh(Object wallet, {required int accountIndex});
|
|
List<Subaddress> getAll(Object wallet);
|
|
Future<void> addSubaddress(Object wallet, {required int accountIndex, required String label});
|
|
Future<void> setLabelSubaddress(Object wallet,
|
|
{required int accountIndex, required int addressIndex, required String label});
|
|
}
|
|
|
|
abstract class WowneroAccountList {
|
|
ObservableList<Account> get accounts;
|
|
void update(Object wallet);
|
|
void refresh(Object wallet);
|
|
List<Account> getAll(Object wallet);
|
|
Future<void> addAccount(Object wallet, {required String label});
|
|
Future<void> setLabelAccount(Object wallet, {required int accountIndex, required String label});
|
|
}
|
|
""";
|
|
|
|
const wowneroEmptyDefinition = 'Wownero? wownero;\n';
|
|
const wowneroCWDefinition = 'Wownero? wownero = CWWownero();\n';
|
|
|
|
final output = '$wowneroCommonHeaders\n' +
|
|
(hasImplementation ? '$wowneroCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$wowneroCwPart\n\n' : '\n') +
|
|
(hasImplementation ? wowneroCWDefinition : wowneroEmptyDefinition) +
|
|
'\n' +
|
|
wowneroContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateBitcoinCash(bool hasImplementation) async {
|
|
final outputFile = File(bitcoinCashOutputPath);
|
|
const bitcoinCashCommonHeaders = """
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:cw_core/unspent_transaction_output.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:hive/hive.dart';
|
|
""";
|
|
const bitcoinCashCWHeaders = """
|
|
import 'package:cw_bitcoin_cash/cw_bitcoin_cash.dart';
|
|
import 'package:cw_bitcoin/bitcoin_transaction_priority.dart';
|
|
""";
|
|
const bitcoinCashCwPart = "part 'cw_bitcoin_cash.dart';";
|
|
const bitcoinCashContent = """
|
|
abstract class BitcoinCash {
|
|
String getCashAddrFormat(String address);
|
|
|
|
WalletService createBitcoinCashWalletService(
|
|
Box<UnspentCoinsInfo> unspentCoinSource, bool isDirect);
|
|
|
|
WalletCredentials createBitcoinCashNewWalletCredentials(
|
|
{required String name, WalletInfo? walletInfo, String? password, String? passphrase, String? mnemonic});
|
|
|
|
WalletCredentials createBitcoinCashRestoreWalletFromSeedCredentials(
|
|
{required String name, required String mnemonic, required String password, String? passphrase});
|
|
|
|
TransactionPriority deserializeBitcoinCashTransactionPriority(int raw);
|
|
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
|
|
TransactionPriority getBitcoinCashTransactionPrioritySlow();
|
|
}
|
|
""";
|
|
|
|
const bitcoinCashEmptyDefinition = 'BitcoinCash? bitcoinCash;\n';
|
|
const bitcoinCashCWDefinition = 'BitcoinCash? bitcoinCash = CWBitcoinCash();\n';
|
|
|
|
final output = '$bitcoinCashCommonHeaders\n' +
|
|
(hasImplementation ? '$bitcoinCashCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$bitcoinCashCwPart\n\n' : '\n') +
|
|
(hasImplementation ? bitcoinCashCWDefinition : bitcoinCashEmptyDefinition) +
|
|
'\n' +
|
|
bitcoinCashContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateNano(bool hasImplementation) async {
|
|
final outputFile = File(nanoOutputPath);
|
|
const nanoCommonHeaders = """
|
|
import 'package:cw_core/cake_hive.dart';
|
|
import 'package:cw_core/nano_account.dart';
|
|
import 'package:cw_core/account.dart';
|
|
import 'package:cw_core/node.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/nano_account_info_response.dart';
|
|
import 'package:cw_core/n2_node.dart';
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:hive/hive.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
""";
|
|
const nanoCWHeaders = """
|
|
import 'package:cw_nano/nano_client.dart';
|
|
import 'package:cw_nano/nano_mnemonic.dart';
|
|
import 'package:cw_nano/nano_wallet.dart';
|
|
import 'package:cw_nano/nano_wallet_service.dart';
|
|
import 'package:cw_nano/nano_transaction_info.dart';
|
|
import 'package:cw_nano/nano_transaction_credentials.dart';
|
|
import 'package:cw_nano/nano_wallet_creation_credentials.dart';
|
|
// needed for nano_util:
|
|
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
import 'package:convert/convert.dart';
|
|
import "package:ed25519_hd_key/ed25519_hd_key.dart";
|
|
import 'package:libcrypto/libcrypto.dart';
|
|
import 'package:nanodart/nanodart.dart' as ND;
|
|
import 'package:nanoutil/nanoutil.dart';
|
|
""";
|
|
const nanoCwPart = "part 'cw_nano.dart';";
|
|
const nanoContent = """
|
|
abstract class Nano {
|
|
NanoAccountList getAccountList(Object wallet);
|
|
|
|
Account getCurrentAccount(Object wallet);
|
|
|
|
void setCurrentAccount(Object wallet, int id, String label, String? balance);
|
|
|
|
WalletService createNanoWalletService(bool isDirect);
|
|
|
|
WalletCredentials createNanoNewWalletCredentials({
|
|
required String name,
|
|
String? password,
|
|
String? mnemonic,
|
|
WalletInfo? walletInfo,
|
|
String? passphrase,
|
|
});
|
|
|
|
WalletCredentials createNanoRestoreWalletFromSeedCredentials({
|
|
required String name,
|
|
required String password,
|
|
required String mnemonic,
|
|
required DerivationType derivationType,
|
|
String? passphrase,
|
|
});
|
|
|
|
WalletCredentials createNanoRestoreWalletFromKeysCredentials({
|
|
required String name,
|
|
required String password,
|
|
required String seedKey,
|
|
required DerivationType derivationType,
|
|
});
|
|
|
|
List<String> getNanoWordList(String language);
|
|
Map<String, String> getKeys(Object wallet);
|
|
Object createNanoTransactionCredentials(List<Output> outputs);
|
|
Future<void> changeRep(Object wallet, String address);
|
|
Future<bool> updateTransactions(Object wallet);
|
|
BigInt getTransactionAmountRaw(TransactionInfo transactionInfo);
|
|
String getRepresentative(Object wallet);
|
|
Future<List<N2Node>> getN2Reps(Object wallet);
|
|
bool isRepOk(Object wallet);
|
|
}
|
|
|
|
abstract class NanoAccountList {
|
|
ObservableList<NanoAccount> get accounts;
|
|
void update(Object wallet);
|
|
void refresh(Object wallet);
|
|
Future<List<NanoAccount>> getAll(Object wallet);
|
|
Future<void> addAccount(Object wallet, {required String label});
|
|
Future<void> setLabelAccount(Object wallet, {required int accountIndex, required String label});
|
|
}
|
|
|
|
abstract class NanoUtil {
|
|
bool isValidBip39Seed(String seed);
|
|
static const int maxDecimalDigits = 6; // Max digits after decimal
|
|
BigInt rawPerNano = BigInt.parse("1000000000000000000000000000000");
|
|
BigInt rawPerNyano = BigInt.parse("1000000000000000000000000");
|
|
BigInt rawPerBanano = BigInt.parse("100000000000000000000000000000");
|
|
BigInt rawPerXMR = BigInt.parse("1000000000000");
|
|
BigInt convertXMRtoNano = BigInt.parse("1000000000000000000");
|
|
String getRawAsUsableString(String? raw, BigInt rawPerCur);
|
|
String getRawAccuracy(String? raw, BigInt rawPerCur);
|
|
String getAmountAsRaw(String amount, BigInt rawPerCur);
|
|
|
|
// derivationInfo:
|
|
Future<AccountInfoResponse?> getInfoFromSeedOrMnemonic(
|
|
DerivationType derivationType, {
|
|
String? seedKey,
|
|
String? mnemonic,
|
|
required Node node,
|
|
});
|
|
Future<List<DerivationType>> compareDerivationMethods({
|
|
String? mnemonic,
|
|
String? privateKey,
|
|
required Node node,
|
|
});
|
|
Future<List<DerivationInfo>> getDerivationsFromMnemonic({
|
|
String? mnemonic,
|
|
String? seedKey,
|
|
required Node node,
|
|
});
|
|
}
|
|
""";
|
|
|
|
const nanoEmptyDefinition = 'Nano? nano;\nNanoUtil? nanoUtil;\n';
|
|
const nanoCWDefinition = 'Nano? nano = CWNano();\nNanoUtil? nanoUtil = CWNanoUtil();\n';
|
|
|
|
final output = '$nanoCommonHeaders\n' +
|
|
(hasImplementation ? '$nanoCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$nanoCwPart\n\n' : '\n') +
|
|
(hasImplementation ? nanoCWDefinition : nanoEmptyDefinition) +
|
|
'\n' +
|
|
nanoContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateSolana(bool hasImplementation) async {
|
|
final outputFile = File(solanaOutputPath);
|
|
const solanaCommonHeaders = """
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cake_wallet/exchange/provider/jupiter_exchange_provider.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/spl_token.dart';
|
|
|
|
""";
|
|
const solanaCWHeaders = """
|
|
import 'package:cw_solana/solana_wallet.dart';
|
|
import 'package:cw_solana/solana_mnemonics.dart';
|
|
import 'package:cw_solana/solana_wallet_service.dart';
|
|
import 'package:cw_solana/solana_transaction_info.dart';
|
|
import 'package:cw_solana/pending_solana_transaction.dart';
|
|
import 'package:cw_solana/solana_transaction_credentials.dart';
|
|
import 'package:cw_solana/solana_wallet_creation_credentials.dart';
|
|
import 'package:cw_solana/default_spl_tokens.dart';
|
|
|
|
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
import 'package:on_chain/solana/solana.dart' hide Store;
|
|
""";
|
|
const solanaCwPart = "part 'cw_solana.dart';";
|
|
const solanaContent = """
|
|
abstract class Solana {
|
|
List<String> getSolanaWordList(String language);
|
|
WalletService createSolanaWalletService(bool isDirect);
|
|
WalletCredentials createSolanaNewWalletCredentials(
|
|
{required String name, WalletInfo? walletInfo, String? password, String? mnemonic, String? passphrase});
|
|
WalletCredentials createSolanaRestoreWalletFromSeedCredentials(
|
|
{required String name, required String mnemonic, required String password, String? passphrase});
|
|
WalletCredentials createSolanaRestoreWalletFromPrivateKey(
|
|
{required String name, required String privateKey, required String password});
|
|
|
|
String getAddress(WalletBase wallet);
|
|
String getPrivateKey(WalletBase wallet);
|
|
String getPublicKey(WalletBase wallet);
|
|
|
|
Object createSolanaTransactionCredentials(
|
|
List<Output> outputs, {
|
|
required CryptoCurrency currency,
|
|
});
|
|
|
|
Object createSolanaTransactionCredentialsRaw(
|
|
List<OutputInfo> outputs, {
|
|
required CryptoCurrency currency,
|
|
});
|
|
List<CryptoCurrency> getSPLTokenCurrencies(WalletBase wallet);
|
|
Future<void> addSPLToken(
|
|
WalletBase wallet,
|
|
CryptoCurrency token,
|
|
String contractAddress,
|
|
);
|
|
Future<void> deleteSPLToken(WalletBase wallet, CryptoCurrency token);
|
|
Future<CryptoCurrency?> getSPLToken(WalletBase wallet, String contractAddress);
|
|
|
|
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
|
|
double getTransactionAmountRaw(TransactionInfo transactionInfo);
|
|
String getTokenAddress(CryptoCurrency asset);
|
|
List<int>? getValidationLength(CryptoCurrency type);
|
|
double? getEstimateFees(WalletBase wallet);
|
|
List<SPLToken> getDefaultSPLTokens();
|
|
List<String> getDefaultTokenContractAddresses();
|
|
List<String> getDefaultTokenSymbols();
|
|
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
|
|
|
// Jupiter swap transaction handling
|
|
// Signs and prepares a base64-encoded unsigned transaction for sending
|
|
Future<PendingTransaction> signAndPrepareJupiterSwapTransaction(
|
|
WalletBase wallet,
|
|
String base64Transaction,
|
|
String requestId,
|
|
String destinationAddress,
|
|
double amount,
|
|
double fee,
|
|
);
|
|
|
|
// Fast transaction update after sending
|
|
// Polls for a specific transaction by signature with exponential backoff
|
|
// Falls back to full refresh if transaction is not found after max retries
|
|
Future<void> pollForTransaction(
|
|
WalletBase wallet,
|
|
String signature, {
|
|
Duration initialDelay = const Duration(seconds: 1),
|
|
int maxRetries = 5,
|
|
});
|
|
|
|
// Updates balances for specific tokens by mint addresses
|
|
// Also updates native SOL balance
|
|
// If tokenMints is null or empty, updates all tokens (full refresh)
|
|
Future<void> updateTokenBalances(
|
|
WalletBase wallet, {
|
|
List<String>? tokenMints,
|
|
});
|
|
}
|
|
|
|
class JupiterSwapFailedException implements Exception {
|
|
final String message;
|
|
final String signature;
|
|
final num? errorCode;
|
|
final String? errorMessage;
|
|
|
|
JupiterSwapFailedException({
|
|
required this.message,
|
|
required this.signature,
|
|
this.errorCode,
|
|
this.errorMessage,
|
|
});
|
|
|
|
@override
|
|
String toString() => message;
|
|
}
|
|
|
|
""";
|
|
|
|
const solanaEmptyDefinition = 'Solana? solana;\n';
|
|
const solanaCWDefinition = 'Solana? solana = CWSolana();\n';
|
|
|
|
final output = '$solanaCommonHeaders\n' +
|
|
(hasImplementation ? '$solanaCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$solanaCwPart\n\n' : '\n') +
|
|
(hasImplementation ? solanaCWDefinition : solanaEmptyDefinition) +
|
|
'\n' +
|
|
solanaContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateTron(bool hasImplementation) async {
|
|
final outputFile = File(tronOutputPath);
|
|
const tronCommonHeaders = """
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/tron_token.dart';
|
|
import 'package:hive/hive.dart';
|
|
|
|
""";
|
|
const tronCWHeaders = """
|
|
import 'package:cw_evm/evm_chain_mnemonics.dart';
|
|
import 'package:cw_tron/tron_transaction_credentials.dart';
|
|
import 'package:cw_tron/tron_transaction_info.dart';
|
|
import 'package:cw_tron/tron_wallet_creation_credentials.dart';
|
|
|
|
import 'package:cw_tron/tron_client.dart';
|
|
import 'package:cw_tron/tron_wallet.dart';
|
|
import 'package:cw_tron/tron_wallet_service.dart';
|
|
import 'package:cw_tron/default_tron_tokens.dart';
|
|
|
|
""";
|
|
const tronCwPart = "part 'cw_tron.dart';";
|
|
const tronContent = """
|
|
abstract class Tron {
|
|
List<String> getTronWordList(String language);
|
|
WalletService createTronWalletService(bool isDirect);
|
|
WalletCredentials createTronNewWalletCredentials({required String name, WalletInfo? walletInfo, String? password, String? mnemonic, String? passphrase});
|
|
WalletCredentials createTronRestoreWalletFromSeedCredentials({required String name, required String mnemonic, required String password, String? passphrase});
|
|
WalletCredentials createTronRestoreWalletFromPrivateKey({required String name, required String privateKey, required String password});
|
|
String getAddress(WalletBase wallet);
|
|
|
|
Object createTronTransactionCredentials(
|
|
List<Output> outputs, {
|
|
required CryptoCurrency currency,
|
|
});
|
|
|
|
List<CryptoCurrency> getTronTokenCurrencies(WalletBase wallet);
|
|
Future<void> addTronToken(WalletBase wallet, CryptoCurrency token, String contractAddress);
|
|
Future<void> deleteTronToken(WalletBase wallet, CryptoCurrency token);
|
|
Future<CryptoCurrency?> getTronToken(WalletBase wallet, String contractAddress);
|
|
|
|
double getTransactionAmountRaw(TransactionInfo transactionInfo);
|
|
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
|
|
String getTokenAddress(CryptoCurrency asset);
|
|
String getTronBase58Address(String hexAddress, WalletBase wallet);
|
|
|
|
String? getTronNativeEstimatedFee(WalletBase wallet);
|
|
String? getTronTRC20EstimatedFee(WalletBase wallet);
|
|
|
|
void updateTronGridUsageState(WalletBase wallet, bool isEnabled);
|
|
List<TronToken> getDefaultTronTokens();
|
|
List<String> getDefaultTokenContractAddresses();
|
|
List<String> getDefaultTokenSymbols();
|
|
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
|
}
|
|
""";
|
|
|
|
const tronEmptyDefinition = 'Tron? tron;\n';
|
|
const tronCWDefinition = 'Tron? tron = CWTron();\n';
|
|
|
|
final output = '$tronCommonHeaders\n' +
|
|
(hasImplementation ? '$tronCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$tronCwPart\n\n' : '\n') +
|
|
(hasImplementation ? tronCWDefinition : tronEmptyDefinition) +
|
|
'\n' +
|
|
tronContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateZano(bool hasImplementation) async {
|
|
final outputFile = File(zanoOutputPath);
|
|
const zanoCommonHeaders = """
|
|
import 'package:cake_wallet/utils/language_list.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:collection/collection.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/monero_transaction_priority.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/zano_asset.dart';
|
|
import 'package:hive/hive.dart';
|
|
""";
|
|
const zanoCWHeaders = """
|
|
import 'package:cw_zano/mnemonics/english.dart';
|
|
import 'package:cw_zano/model/zano_transaction_credentials.dart';
|
|
import 'package:cw_zano/model/zano_transaction_info.dart';
|
|
import 'package:cw_zano/zano_formatter.dart';
|
|
import 'package:cw_zano/zano_wallet.dart';
|
|
import 'package:cw_zano/zano_wallet_service.dart';
|
|
import 'package:cw_zano/zano_wallet_api.dart' as api;
|
|
import 'package:cw_zano/zano_utils.dart';
|
|
""";
|
|
const zanoCwPart = "part 'cw_zano.dart';";
|
|
const zanoContent = """
|
|
abstract class Zano {
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
TransactionPriority deserializeMoneroTransactionPriority({required int raw});
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
List<String> getWordList(String language);
|
|
|
|
WalletCredentials createZanoRestoreWalletFromSeedCredentials({required String name, required String password, required String passphrase, required int height, required String mnemonic});
|
|
WalletCredentials createZanoNewWalletCredentials({required String name, required String? password, required String? passphrase});
|
|
Map<String, String> getKeys(Object wallet);
|
|
Object createZanoTransactionCredentials({required List<Output> outputs, required TransactionPriority priority, required CryptoCurrency currency});
|
|
double formatterIntAmountToDouble({required int amount, required CryptoCurrency currency, required bool forFee});
|
|
int formatterParseAmount({required String amount, required CryptoCurrency currency});
|
|
WalletService createZanoWalletService();
|
|
CryptoCurrency? assetOfTransaction(WalletBase wallet, TransactionInfo tx);
|
|
List<ZanoAsset> getZanoAssets(WalletBase wallet);
|
|
String getZanoAssetAddress(CryptoCurrency asset);
|
|
Future<void> changeZanoAssetAvailability(WalletBase wallet, CryptoCurrency token);
|
|
Future<CryptoCurrency> addZanoAssetById(WalletBase wallet, String assetId);
|
|
Future<void> deleteZanoAsset(WalletBase wallet, CryptoCurrency token);
|
|
Future<CryptoCurrency?> getZanoAsset(WalletBase wallet, String contractAddress);
|
|
String getAddress(WalletBase wallet);
|
|
bool validateAddress(String address);
|
|
Map<String, List<int>> debugCallLength();
|
|
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
|
}
|
|
""";
|
|
const zanoEmptyDefinition = 'Zano? zano;\n';
|
|
const zanoCWDefinition = 'Zano? zano = CWZano();\n';
|
|
|
|
final output = '$zanoCommonHeaders\n' +
|
|
(hasImplementation ? '$zanoCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$zanoCwPart\n\n' : '\n') +
|
|
(hasImplementation ? zanoCWDefinition : zanoEmptyDefinition) +
|
|
'\n' +
|
|
zanoContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateDecred(bool hasImplementation) async {
|
|
final outputFile = File(decredOutputPath);
|
|
const decredCommonHeaders = """
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/address_info.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/unspent_transaction_output.dart';
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:hive/hive.dart';
|
|
""";
|
|
const decredCWHeaders = """
|
|
import 'package:cw_decred/transaction_priority.dart';
|
|
import 'package:cw_decred/wallet.dart';
|
|
import 'package:cw_decred/wallet_service.dart';
|
|
import 'package:cw_decred/wallet_creation_credentials.dart';
|
|
import 'package:cw_decred/amount_format.dart';
|
|
import 'package:cw_decred/transaction_credentials.dart';
|
|
import 'package:cw_decred/mnemonic.dart';
|
|
""";
|
|
const decredCwPart = "part 'cw_decred.dart';";
|
|
const decredContent = """
|
|
|
|
abstract class Decred {
|
|
WalletCredentials createDecredNewWalletCredentials(
|
|
{required String name, WalletInfo? walletInfo});
|
|
WalletCredentials createDecredRestoreWalletFromSeedCredentials(
|
|
{required String name, required String mnemonic, required String password});
|
|
WalletCredentials createDecredRestoreWalletFromPubkeyCredentials(
|
|
{required String name, required String pubkey, required String password});
|
|
WalletService createDecredWalletService(Box<UnspentCoinsInfo> unspentCoinSource);
|
|
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
TransactionPriority getDecredTransactionPriorityMedium();
|
|
TransactionPriority getDecredTransactionPrioritySlow();
|
|
TransactionPriority deserializeDecredTransactionPriority(int raw);
|
|
|
|
Object createDecredTransactionCredentials(List<Output> outputs, TransactionPriority priority);
|
|
|
|
List<WalletInfoAddressInfo> getAddressInfos(Object wallet);
|
|
Future<void> updateAddress(Object wallet, String address, String label);
|
|
Future<void> generateNewAddress(Object wallet, String label);
|
|
|
|
String formatterDecredAmountToString({required int amount});
|
|
double formatterDecredAmountToDouble({required int amount});
|
|
int formatterStringDoubleToDecredAmount(String amount);
|
|
|
|
List<Unspent> getUnspents(Object wallet);
|
|
void updateUnspents(Object wallet);
|
|
|
|
int heightByDate(DateTime date);
|
|
|
|
List<String> getDecredWordList();
|
|
|
|
String pubkey(Object wallet);
|
|
}
|
|
""";
|
|
|
|
const decredEmptyDefinition = 'Decred? decred;\n';
|
|
const decredCWDefinition = 'Decred? decred = CWDecred();\n';
|
|
|
|
final output = '$decredCommonHeaders\n' +
|
|
(hasImplementation ? '$decredCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$decredCwPart\n\n' : '\n') +
|
|
(hasImplementation ? decredCWDefinition : decredEmptyDefinition) +
|
|
'\n' +
|
|
decredContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateDogecoin(bool hasImplementation) async {
|
|
final outputFile = File(dogecoinOutputPath);
|
|
const dogecoinCommonHeaders = """
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/unspent_coins_info.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:hive/hive.dart';
|
|
""";
|
|
const dogecoinCWHeaders = """
|
|
import 'package:cw_dogecoin/cw_dogecoin.dart';
|
|
""";
|
|
const dogecoinCwPart = "part 'cw_dogecoin.dart';";
|
|
const dogecoinContent = """
|
|
abstract class DogeCoin {
|
|
|
|
WalletService createDogeCoinWalletService(Box<UnspentCoinsInfo> unspentCoinSource, bool isDirect);
|
|
|
|
WalletCredentials createDogeCoinNewWalletCredentials(
|
|
{required String name, WalletInfo? walletInfo, String? password, String? passphrase, String? mnemonic});
|
|
|
|
WalletCredentials createDogeCoinRestoreWalletFromSeedCredentials(
|
|
{required String name, required String mnemonic, required String password, String? passphrase});
|
|
|
|
TransactionPriority deserializeDogeCoinTransactionPriority(int raw);
|
|
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
|
|
TransactionPriority getDogeCoinTransactionPrioritySlow();
|
|
}
|
|
""";
|
|
|
|
const dogecoinEmptyDefinition = 'DogeCoin? dogecoin;\n';
|
|
const dogecoinCWDefinition = 'DogeCoin? dogecoin = CWDogeCoin();\n';
|
|
|
|
final output = '$dogecoinCommonHeaders\n' +
|
|
(hasImplementation ? '$dogecoinCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$dogecoinCwPart\n\n' : '\n') +
|
|
(hasImplementation ? dogecoinCWDefinition : dogecoinEmptyDefinition) +
|
|
'\n' +
|
|
dogecoinContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateEVM(bool hasImplementation) async {
|
|
final outputFile = File(evmOutputPath);
|
|
const evmCommonHeaders = """
|
|
import 'dart:math' as math;
|
|
import 'package:cake_wallet/core/utilities.dart';
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/erc20_token.dart';
|
|
import 'package:cw_core/hardware/hardware_account_data.dart';
|
|
import 'package:cw_core/hardware/hardware_wallet_service.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:cw_core/node.dart';
|
|
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
|
|
import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
|
|
import 'package:trezor_connect/trezor_connect.dart' as trezor;
|
|
import 'package:web3dart/web3dart.dart';
|
|
|
|
""";
|
|
const evmCWHeaders = """
|
|
import 'package:cake_wallet/core/fiat_conversion_service.dart';
|
|
import 'package:cake_wallet/di.dart';
|
|
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
import 'package:cw_evm/utils/evm_chain_formatter.dart';
|
|
import 'package:cw_evm/evm_chain_mnemonics.dart';
|
|
import 'package:cw_evm/evm_chain_registry.dart';
|
|
import 'package:cw_evm/evm_erc20_balance.dart';
|
|
import 'package:cw_evm/evm_chain_transaction_credentials.dart';
|
|
import 'package:cw_evm/evm_chain_transaction_info.dart';
|
|
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
|
import 'package:cw_evm/hardware/evm_chain_bitbox_credentials.dart';
|
|
import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
|
|
import 'package:cw_evm/hardware/evm_chain_trezor_credentials.dart';
|
|
import 'package:cw_evm/evm_chain_wallet.dart';
|
|
import 'package:cw_evm/hardware/evm_chain_bitbox_service.dart';
|
|
import 'package:cw_evm/hardware/evm_chain_ledger_service.dart';
|
|
import 'package:cw_evm/hardware/evm_chain_trezor_service.dart';
|
|
import 'package:cw_evm/evm_chain_wallet_service.dart';
|
|
import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
|
|
import 'package:cw_evm/utils/evm_chain_utils.dart';
|
|
import 'package:cw_evm/evm_chain_default_tokens.dart';
|
|
import 'package:cw_evm/deuro/deuro_savings.dart';
|
|
import 'package:eth_sig_util/util/utils.dart';
|
|
|
|
""";
|
|
const evmCwPart = "part 'cw_evm.dart';";
|
|
const evmContent = """
|
|
/// Unified abstract class for all EVM chains
|
|
///
|
|
/// This replaces separate proxy classes (Ethereum, Polygon, Base, Arbitrum)
|
|
/// with a single unified interface that works for all EVM chains.
|
|
/// Methods take WalletType parameter to determine chain-specific behavior.
|
|
abstract class EVM {
|
|
List<String> getEVMWordList(String language);
|
|
|
|
/// Create unified wallet service for any EVM chain
|
|
WalletService createEVMWalletService(WalletType walletType, bool isDirect);
|
|
|
|
/// Generic credential creation - uses WalletType
|
|
WalletCredentials createEVMNewWalletCredentials({
|
|
required String name,
|
|
WalletInfo? walletInfo,
|
|
String? password,
|
|
String? mnemonic,
|
|
String? passphrase,
|
|
});
|
|
|
|
WalletCredentials createEVMRestoreWalletFromSeedCredentials({
|
|
required String name,
|
|
required String mnemonic,
|
|
required String password,
|
|
String? passphrase,
|
|
});
|
|
|
|
WalletCredentials createEVMRestoreWalletFromPrivateKey({
|
|
required String name,
|
|
required String privateKey,
|
|
required String password,
|
|
});
|
|
|
|
WalletCredentials createEVMHardwareWalletCredentials({
|
|
required String name,
|
|
required HardwareAccountData hwAccountData,
|
|
WalletInfo? walletInfo,
|
|
});
|
|
|
|
// Generic methods that work for all EVM chains
|
|
String getAddress(WalletBase wallet);
|
|
String getPrivateKey(WalletBase wallet);
|
|
String getPublicKey(WalletBase wallet);
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
TransactionPriority getEVMTransactionPrioritySlow();
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
TransactionPriority deserializeEVMTransactionPriority(int raw);
|
|
|
|
Object createEVMTransactionCredentials(
|
|
List<Output> outputs, {
|
|
required TransactionPriority? priority,
|
|
required CryptoCurrency currency,
|
|
int? feeRate,
|
|
bool useBlinkProtection = true,
|
|
});
|
|
|
|
Object createEVMTransactionCredentialsRaw(
|
|
List<OutputInfo> outputs, {
|
|
TransactionPriority? priority,
|
|
required CryptoCurrency currency,
|
|
required int feeRate,
|
|
bool useBlinkProtection = true,
|
|
});
|
|
|
|
int formatterEVMParseAmount(String amount);
|
|
double formatterEVMAmountToDouble({
|
|
TransactionInfo? transaction,
|
|
BigInt? amount,
|
|
int exponent = 18,
|
|
});
|
|
|
|
List<Erc20Token> getERC20Currencies(WalletBase wallet);
|
|
Future<void> addErc20Token(WalletBase wallet, CryptoCurrency token);
|
|
Future<void> deleteErc20Token(WalletBase wallet, CryptoCurrency token);
|
|
Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token);
|
|
Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress);
|
|
|
|
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
|
|
void updateScanProviderUsageState(WalletBase wallet, bool isEnabled);
|
|
Web3Client? getWeb3Client(WalletBase wallet);
|
|
String getTokenAddress(CryptoCurrency asset);
|
|
BigInt? getERC20AvailableBalance(Object balance);
|
|
|
|
Future<bool> isApprovalRequired(
|
|
WalletBase wallet,
|
|
String tokenContract,
|
|
String spender,
|
|
BigInt requiredAmount,
|
|
);
|
|
|
|
Future<BigInt?> getAllowance(
|
|
WalletBase wallet,
|
|
String tokenContract,
|
|
String spender);
|
|
|
|
Future<PendingTransaction> createTokenApproval(
|
|
WalletBase wallet,
|
|
BigInt amount,
|
|
String spender,
|
|
CryptoCurrency token,
|
|
TransactionPriority? priority,
|
|
{bool useBlinkProtection = true}
|
|
);
|
|
|
|
Future<PendingTransaction> createRawCallDataTransaction(
|
|
WalletBase wallet,
|
|
String to,
|
|
String dataHex,
|
|
BigInt valueWei,
|
|
TransactionPriority? priority,
|
|
{bool useBlinkProtection = true,
|
|
String? sourceTokenAddress,
|
|
BigInt? sourceTokenAmount}
|
|
);
|
|
|
|
// Hardware wallet methods
|
|
Future<void> setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
|
|
HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection);
|
|
HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
|
|
HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect);
|
|
|
|
// Utility methods
|
|
List<Erc20Token> getDefaultTokensByChainId(int chainId);
|
|
List<String> getDefaultTokenContractAddresses(WalletBase wallet);
|
|
List<String> getDefaultTokenSymbols(WalletBase wallet);
|
|
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
|
String? getEVMNativeEstimatedFee(WalletBase wallet);
|
|
String? getEVMERC20EstimatedFee(WalletBase wallet);
|
|
|
|
// Chain-specific integrations (optional, can be null for non-Ethereum chains)
|
|
Future<BigInt>? getDEuroSavingsBalance(WalletBase wallet) => null;
|
|
Future<BigInt>? getDEuroAccruedInterest(WalletBase wallet) => null;
|
|
Future<BigInt>? getDEuroInterestRate(WalletBase wallet) => null;
|
|
Future<BigInt>? getDEuroSavingsApproved(WalletBase wallet) => null;
|
|
Future<PendingTransaction>? addDEuroSaving(WalletBase wallet, BigInt amount, TransactionPriority priority) => null;
|
|
Future<PendingTransaction>? removeDEuroSaving(WalletBase wallet, BigInt amount, TransactionPriority priority) => null;
|
|
Future<PendingTransaction>? reinvestDEuroInterest(WalletBase wallet, TransactionPriority priority) => null;
|
|
Future<PendingTransaction>? enableDEuroSaving(WalletBase wallet, TransactionPriority priority) => null;
|
|
|
|
// Registry helper methods (for backward compatibility helpers)
|
|
int getChainIdByWalletType(WalletType walletType);
|
|
String getChainNameByWalletType(WalletType walletType);
|
|
String getTokenNameByWalletType(WalletType walletType);
|
|
String getCaip2ByChainId(int chainId);
|
|
int? getChainIdByTag(String tag);
|
|
int? getChainIdByTitle(String title);
|
|
WalletType? getWalletTypeByChainId(int chainId);
|
|
String getChainNameByChainId(int chainId);
|
|
String getTokenNameByChainId(int chainId);
|
|
|
|
// Chain selection methods
|
|
List<ChainInfo> getAllChains();
|
|
ChainInfo? getCurrentChain(WalletBase wallet);
|
|
|
|
int? getSelectedChainId(WalletBase wallet);
|
|
Future<void> selectChain(WalletBase wallet, int chainId, {required Node node});
|
|
|
|
String? getExplorerUrlForChainId(int chainId, {bool showProtocol = true});
|
|
|
|
bool hasPriorityFee(int chainId);
|
|
|
|
Future<void> discoverAndAddWalletTokens(WalletBase wallet);
|
|
}
|
|
|
|
class ChainInfo {
|
|
const ChainInfo({
|
|
required this.chainId,
|
|
required this.name,
|
|
required this.shortCode,
|
|
});
|
|
|
|
final int chainId;
|
|
final String name;
|
|
final String shortCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is ChainInfo && runtimeType == other.runtimeType && chainId == other.chainId;
|
|
|
|
@override
|
|
int get hashCode => chainId.hashCode;
|
|
}
|
|
""";
|
|
|
|
const evmEmptyDefinition = 'EVM? evm;\n';
|
|
const evmCWDefinition = 'EVM? evm = CWEVM();\n';
|
|
|
|
final output = '$evmCommonHeaders\n' +
|
|
(hasImplementation ? '$evmCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$evmCwPart\n\n' : '\n') +
|
|
(hasImplementation ? evmCWDefinition : evmEmptyDefinition) +
|
|
'\n' +
|
|
evmContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generateZcash(bool hasImplementation) async {
|
|
final outputFile = File(zcashOutputPath);
|
|
const zcashCommonHeaders = """
|
|
import 'package:cake_wallet/view_model/send/output.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/crypto_amount_format.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/output_info.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/monero_transaction_priority.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_credentials.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_service.dart';
|
|
import 'package:cw_core/receive_page_option.dart';
|
|
|
|
""";
|
|
const zcashCWHeaders = """
|
|
import 'package:cw_zcash/cw_zcash.dart';
|
|
import 'package:cw_zcash/src/zcash_wallet_addresses.dart';
|
|
|
|
""";
|
|
const zcashCwPart = "part 'cw_zcash.dart';";
|
|
const zcashContent = """
|
|
abstract class Zcash {
|
|
List<String> getZcashWordList(String language);
|
|
WalletService createZcashWalletService(bool isDirect);
|
|
WalletCredentials createZcashNewWalletCredentials(
|
|
{required String name,
|
|
WalletInfo? walletInfo,
|
|
String? password,
|
|
String? mnemonic,
|
|
required String? passphrase});
|
|
WalletCredentials createZcashRestoreWalletFromSeedCredentials(
|
|
{required String name,
|
|
required String mnemonic,
|
|
required String password,
|
|
String? passphrase,
|
|
required int? height});
|
|
WalletCredentials createZcashRestoreWalletFromPrivateKey(
|
|
{required String name, required String privateKey, required String password, required int height});
|
|
String getAddress(WalletBase wallet);
|
|
String getPrivateKey(WalletBase wallet);
|
|
String getPublicKey(WalletBase wallet);
|
|
Map<String, String> getKeys(Object wallet);
|
|
|
|
Object createZcashTransactionCredentials(
|
|
List<Output> outputs, {
|
|
required CryptoCurrency currency,
|
|
int? feeRate,
|
|
});
|
|
|
|
Object createZcashTransactionCredentialsRaw(
|
|
List<OutputInfo> outputs, {
|
|
required CryptoCurrency currency,
|
|
required int feeRate,
|
|
});
|
|
|
|
int formatterZcashParseAmount(String amount);
|
|
double formatterZcashAmountToDouble({TransactionInfo? transaction, BigInt? amount});
|
|
String formatterZcashAmountToString({required int amount});
|
|
|
|
List<WalletInfoAddressInfo> getAddressInfos(Object wallet);
|
|
|
|
TransactionPriority getDefaultTransactionPriority();
|
|
TransactionPriority getZcashTransactionPriorityAutomatic();
|
|
TransactionPriority deserializeZcashTransactionPriority({required int raw});
|
|
List<TransactionPriority> getTransactionPriorities();
|
|
ReceivePageOption getSelectedAddressType(Object wallet);
|
|
dynamic getZcashAddressType(ReceivePageOption option);
|
|
bool hasSelectedTransparentAddress(Object wallet);
|
|
Future<void> setAddressType(Object wallet, dynamic option);
|
|
dynamic getOptionToType(ReceivePageOption option);
|
|
void unlockDatabase(String password);
|
|
Future<int> getHeightByDate(DateTime date);
|
|
bool showMissingFundsCard(WalletBase wallet);
|
|
Future<void> rescanInternalChange(WalletBase wallet);
|
|
}
|
|
""";
|
|
|
|
const zcashEmptyDefinition = 'Zcash? zcash;\n';
|
|
const zcashCWDefinition = 'Zcash? zcash = CWZcash();\n';
|
|
|
|
final output = '$zcashCommonHeaders\n' +
|
|
(hasImplementation ? '$zcashCWHeaders\n' : '\n') +
|
|
(hasImplementation ? '$zcashCwPart\n\n' : '\n') +
|
|
(hasImplementation ? zcashCWDefinition : zcashEmptyDefinition) +
|
|
'\n' +
|
|
zcashContent;
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|
|
|
|
Future<void> generatePubspec({
|
|
required bool hasMonero,
|
|
required bool hasBitcoin,
|
|
required bool hasEthereum,
|
|
required bool hasNano,
|
|
required bool hasBanano,
|
|
required bool hasBitcoinCash,
|
|
required bool hasFlutterSecureStorage,
|
|
required bool hasPolygon,
|
|
required bool hasSolana,
|
|
required bool hasTron,
|
|
required bool hasWownero,
|
|
required bool hasZano,
|
|
required bool hasDecred,
|
|
required bool hasDogecoin,
|
|
required bool hasBase,
|
|
required bool hasArbitrum,
|
|
required bool hasBsc,
|
|
required bool hasZcash,
|
|
}) async {
|
|
const cwCore = """
|
|
cw_core:
|
|
path: ./cw_core
|
|
""";
|
|
const cwMonero = """
|
|
cw_monero:
|
|
path: ./cw_monero
|
|
""";
|
|
const cwBitcoin = """
|
|
cw_bitcoin:
|
|
path: ./cw_bitcoin
|
|
""";
|
|
const flutterSecureStorage = """
|
|
flutter_secure_storage:
|
|
git:
|
|
url: https://github.com/cake-tech/flutter_secure_storage.git
|
|
path: flutter_secure_storage
|
|
ref: ca897a08677edb443b366352dd7412735e098e7b
|
|
""";
|
|
const cwBitcoinCash = """
|
|
cw_bitcoin_cash:
|
|
path: ./cw_bitcoin_cash
|
|
""";
|
|
const cwNano = """
|
|
cw_nano:
|
|
path: ./cw_nano
|
|
""";
|
|
const cwBanano = """
|
|
cw_banano:
|
|
path: ./cw_banano
|
|
""";
|
|
const cwSolana = """
|
|
cw_solana:
|
|
path: ./cw_solana
|
|
""";
|
|
const cwEVM = """
|
|
cw_evm:
|
|
path: ./cw_evm
|
|
""";
|
|
const cwTron = """
|
|
cw_tron:
|
|
path: ./cw_tron
|
|
""";
|
|
const cwWownero = """
|
|
cw_wownero:
|
|
path: ./cw_wownero
|
|
""";
|
|
const cwZano = """
|
|
cw_zano:
|
|
path: ./cw_zano
|
|
""";
|
|
const cwDecred = """
|
|
cw_decred:
|
|
path: ./cw_decred
|
|
""";
|
|
const cwDogecoin = """
|
|
cw_dogecoin:
|
|
path: ./cw_dogecoin
|
|
""";
|
|
const cwZcash = """
|
|
cw_zcash:
|
|
path: ./cw_zcash
|
|
""";
|
|
|
|
final inputFile = File(pubspecOutputPath);
|
|
final inputText = await inputFile.readAsString();
|
|
final inputLines = inputText.split('\n');
|
|
final dependenciesIndex = inputLines.indexWhere((line) => Platform.isWindows
|
|
// On Windows it could contains `\r` (Carriage Return). It could be fixed in newer dart versions.
|
|
? line.toLowerCase() == 'dependencies:\r' || line.toLowerCase() == 'dependencies:'
|
|
: line.toLowerCase() == 'dependencies:');
|
|
var output = cwCore;
|
|
|
|
if (hasMonero) {
|
|
output += '\n$cwMonero';
|
|
}
|
|
|
|
if (hasBitcoin) {
|
|
output += '\n$cwBitcoin';
|
|
}
|
|
|
|
if (hasNano) {
|
|
output += '\n$cwNano';
|
|
}
|
|
|
|
if (hasBanano) {
|
|
output += '\n$cwBanano';
|
|
}
|
|
|
|
if (hasBitcoinCash) {
|
|
output += '\n$cwBitcoinCash';
|
|
}
|
|
|
|
if (hasSolana) {
|
|
output += '\n$cwSolana';
|
|
}
|
|
|
|
if (hasTron) {
|
|
output += '\n$cwTron';
|
|
}
|
|
|
|
if (hasDecred) {
|
|
output += '\n$cwDecred';
|
|
}
|
|
|
|
if (hasFlutterSecureStorage) {
|
|
output += '\n$flutterSecureStorage\n';
|
|
}
|
|
|
|
if (hasEthereum || hasPolygon || hasBase || hasArbitrum || hasBsc) {
|
|
output += '\n$cwEVM';
|
|
}
|
|
|
|
if (hasWownero) {
|
|
output += '\n$cwWownero';
|
|
}
|
|
|
|
if (hasZano) {
|
|
output += '\n$cwZano';
|
|
}
|
|
|
|
if (hasDogecoin) {
|
|
output += '\n$cwDogecoin';
|
|
}
|
|
|
|
if (hasZcash) {
|
|
output += '\n$cwZcash';
|
|
}
|
|
|
|
final outputLines = output.split('\n');
|
|
inputLines.insertAll(dependenciesIndex + 1, outputLines);
|
|
final outputContent = inputLines.join('\n');
|
|
final outputFile = File(pubspecOutputPath);
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(outputContent);
|
|
}
|
|
|
|
Future<void> generateWalletTypes({
|
|
required bool hasMonero,
|
|
required bool hasBitcoin,
|
|
required bool hasEthereum,
|
|
required bool hasNano,
|
|
required bool hasBanano,
|
|
required bool hasBitcoinCash,
|
|
required bool hasPolygon,
|
|
required bool hasSolana,
|
|
required bool hasTron,
|
|
required bool hasWownero,
|
|
required bool hasZano,
|
|
required bool hasDecred,
|
|
required bool hasDogecoin,
|
|
required bool hasBase,
|
|
required bool hasArbitrum,
|
|
required bool hasBsc,
|
|
required bool hasZcash,
|
|
}) async {
|
|
final walletTypesFile = File(walletTypesPath);
|
|
|
|
if (walletTypesFile.existsSync()) {
|
|
await walletTypesFile.delete();
|
|
}
|
|
|
|
const outputHeader = "import 'package:cw_core/wallet_type.dart';";
|
|
const outputDefinition = 'final availableWalletTypes = <WalletType>[';
|
|
var outputContent = outputHeader + '\n\n' + outputDefinition + '\n';
|
|
|
|
if (hasMonero) {
|
|
outputContent += '\tWalletType.monero,\n';
|
|
}
|
|
|
|
if (hasBitcoin) {
|
|
outputContent += '\tWalletType.bitcoin,\n';
|
|
}
|
|
|
|
if (hasEthereum) {
|
|
outputContent += '\tWalletType.ethereum,\n';
|
|
}
|
|
|
|
if (hasBsc) {
|
|
outputContent += '\tWalletType.bsc,\n';
|
|
}
|
|
|
|
if (hasSolana) {
|
|
outputContent += '\tWalletType.solana,\n';
|
|
}
|
|
|
|
if (hasZcash) {
|
|
outputContent += '\tWalletType.zcash,\n';
|
|
}
|
|
|
|
if (hasTron) {
|
|
outputContent += '\tWalletType.tron,\n';
|
|
}
|
|
|
|
if (hasDogecoin) {
|
|
outputContent += '\tWalletType.dogecoin,\n';
|
|
}
|
|
|
|
if (hasBitcoinCash) {
|
|
outputContent += '\tWalletType.bitcoinCash,\n';
|
|
}
|
|
|
|
if (hasBitcoin) {
|
|
outputContent += '\tWalletType.litecoin,\n';
|
|
}
|
|
|
|
if (hasBase) {
|
|
outputContent += '\tWalletType.base,\n';
|
|
}
|
|
|
|
if (hasArbitrum) {
|
|
outputContent += '\tWalletType.arbitrum,\n';
|
|
}
|
|
|
|
if (hasPolygon) {
|
|
outputContent += '\tWalletType.polygon,\n';
|
|
}
|
|
|
|
if (hasNano) {
|
|
outputContent += '\tWalletType.nano,\n';
|
|
}
|
|
|
|
if (hasDecred) {
|
|
outputContent += '\tWalletType.decred,\n';
|
|
}
|
|
|
|
if (hasZano) {
|
|
outputContent += '\tWalletType.zano,\n';
|
|
}
|
|
|
|
if (hasBanano) {
|
|
outputContent += '\tWalletType.banano,\n';
|
|
}
|
|
|
|
// if (hasWownero) {
|
|
// outputContent += '\tWalletType.wownero,\n';
|
|
// }
|
|
|
|
outputContent += '];\n';
|
|
await walletTypesFile.writeAsString(outputContent);
|
|
}
|
|
|
|
Future<void> injectSecureStorage(bool hasFlutterSecureStorage) async {
|
|
const flutterSecureStorageHeader = """
|
|
import 'dart:async';
|
|
import 'dart:io';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
""";
|
|
const abstractSecureStorage = """
|
|
abstract class SecureStorage {
|
|
Future<String?> read({required String key});
|
|
Future<void> write({required String key, required String? value});
|
|
Future<void> delete({required String key});
|
|
Future<void> deleteAll();
|
|
// Legacy
|
|
Future<String?> readNoIOptions({required String key});
|
|
Future<Map<String, String>> readAll();
|
|
}""";
|
|
const defaultSecureStorage = """
|
|
class DefaultSecureStorage extends SecureStorage {
|
|
DefaultSecureStorage._(this._secureStorage);
|
|
|
|
factory DefaultSecureStorage() => _instance;
|
|
|
|
static final _instance = DefaultSecureStorage._(FlutterSecureStorage(
|
|
iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock),
|
|
aOptions: AndroidOptions(encryptedSharedPreferences: true),
|
|
));
|
|
|
|
final FlutterSecureStorage _secureStorage;
|
|
|
|
@override
|
|
Future<String?> read({required String key}) async => await _readInternal(key, false);
|
|
|
|
@override
|
|
Future<void> write({required String key, required String? value}) async {
|
|
// delete the value before writing on macOS because of a weird bug
|
|
// https://github.com/mogol/flutter_secure_storage/issues/581
|
|
if (Platform.isMacOS) {
|
|
await _secureStorage.delete(key: key);
|
|
}
|
|
await _secureStorage.write(key: key, value: value);
|
|
}
|
|
|
|
@override
|
|
Future<void> delete({required String key}) async => _secureStorage.delete(key: key);
|
|
|
|
@override
|
|
Future<void> deleteAll() async => _secureStorage.deleteAll();
|
|
|
|
@override
|
|
Future<String?> readNoIOptions({required String key}) async => await _readInternal(key, true);
|
|
|
|
Future<String?> _readInternal(String key, bool useNoIOptions) async {
|
|
return await _secureStorage.read(
|
|
key: key,
|
|
iOptions: useNoIOptions ? IOSOptions() : null,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<Map<String, String>> readAll() async {
|
|
return await _secureStorage.readAll();
|
|
}
|
|
}""";
|
|
const fakeSecureStorage = """
|
|
class FakeSecureStorage extends SecureStorage {
|
|
@override
|
|
Future<String?> read({required String key}) async => null;
|
|
@override
|
|
Future<void> write({required String key, required String? value}) async {}
|
|
@override
|
|
Future<void> delete({required String key}) async {}
|
|
@override
|
|
Future<void> deleteAll() async {}
|
|
@override
|
|
Future<String?> readNoIOptions({required String key}) async => null;
|
|
@override
|
|
Future<Map<String, String>> readAll() async => {};
|
|
}""";
|
|
final outputFile = File(secureStoragePath);
|
|
final header = hasFlutterSecureStorage
|
|
? '${flutterSecureStorageHeader}\n\nfinal SecureStorage secureStorageShared = DefaultSecureStorage();\n'
|
|
: 'final SecureStorage secureStorageShared = FakeSecureStorage();\n';
|
|
var output = '';
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
output += '${header}\n${abstractSecureStorage}\n\n';
|
|
|
|
if (hasFlutterSecureStorage) {
|
|
output += '${defaultSecureStorage}\n';
|
|
} else {
|
|
output += '${fakeSecureStorage}\n';
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
}
|