Add decred (#1938)

* decred: Add decred. (#1322)

* multi: Add initial decred screens. (#1165)

Use a mock libwallet for now.

* cw_decred: add libdcrwallet dependency and link library for android, ios and macos (#1240)

* change cw_decred from package to plugin

* add libdcrwallet dependency and link library for android, ios and macos

* remove spvwallet, make some libdcrwallet fns async, light refactor

* libdcrwallet: use json payload returns

* use specific libwallet commit hash

* decred: fix Rename wallet.

---------

Co-authored-by: JoeGruff <joegruffins@gmail.com>

* decred: Add sync.

* decred: Add send transaction.

* decred: Fix fee estimation.

* decred: List transactions.

* decred: Add rescan.

* decred: Sign message.

* decred: Add new addr and addrs.

* decred: Add change wallet pass.

* decred: Add restore from seed.

* decred: Add watching only wallets.

* decred: Enable mainnet.

* decred: Allow using blank node address.

This allows a persistent peer to be unset, falling back to decred
seeders.

* decred: Rescan from wallet birthday.

* add and update macos build scripts, update build readme, gitignore macos project.pbxproj

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>

* multi: hide decred rescan page if it's not ready

-  move hasRescan method to WalletBase and implement for decred

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>

* cw_decred: fix bug where decred wallets are not loaded after app restart

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>

* add buy and sell for decred via onramp

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>

* bug-fix: account for other send outputs that are part of the same tx

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>

* decred: Return address with no peers.

* decred: Update pubspec.

* decred: Add verify message.

* upgrade hive_generator dep in cw_decred

* decred: Clean up code.

---------

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
Co-authored-by: Wisdom Arerosuoghene <wisdom.arerosuoghene@gmail.com>
Co-authored-by: Philemon Ukane <ukanephilemon@gmail.com>

* fix extracted addresses not used
fix conflicts with main

* remove print [skip ci]

* minor formatting

* fix initial migration version

* add build decred script to workflow

* install go before build decred
fix switch cases

* trial 2 to fix decred build

* re-install go

* revert build script change

* refactor/clean nodes functions

* Fix address book issue
Fix send ALL (to be continued with the fees point)

* Fix transactions display issues
Add missing file

* Fix unconfirmed balance not displayed
Change Wallet order
Minor cleanup

* Fix workflow

* Fix workflow

* Fix workflow

* test

* hardcode path for now

* fix + cleanup decred build script to work on mac and linux

* Update decred build script

* Run actions on pull requests, extract commit message

* run after checkout

* add safe directory

* Get commit message from base.sha instead of last commit

* base -> head

* Do not merge main branch into pr

* [skip slack] [run tests] clone by sha

* Proper name for decred library in the build script

* Throw an error when ANDROID_HOME or ANDROID_NDK_VERSION is missing

* Fix conflicts with main

* minor code enhancement

* decred: Add used address history.  (#1941)

* decred: Update pubspec.

* decred testnet

* decred: Add used address history.

* decred: Remove default node list.

* populate transaction history before sync begins

* decred: Add some awaits.

* decred: Fix send all.

* decred: Add clang export to build script.

* decred: Update logo colors.

* cleanup cw_decred.dart

* make decred wallet addresses selectable in receive page

* decred: Always set default addr when used.

* decred: Add back default node list.

* decred: Allow creating addresses manually.

---------

Co-authored-by: Wisdom Arerosuoghene <wisdom.arerosuoghene@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* minor fixes and cleanup

* minor fix, feel free to test now

* - Fix transaction details
- Fix Nodes
- Add processing sync status

* Add decred info card

* push missing file

* Add missing text for decred info card

* minor: change docs link [skip ci]

* decred: Update derivation info. (#2013)

* decred: Update derivation info.

* decred: Allow unsynced unused addresses.

* decred: Update dcrwallet dep to 4.3.0.

* Merge main and fix conflicts

* Merge main and fix conflicts

* decred: Fix background sync panic. (#2080)

* decred: Run libwallet in isolate. (#2077)

* decred: Fix contact save inquiry. (#2083)

Also fix tx time and the fee shown on pending transactions.

* Disable send button in view only decred wallets

* - Fix frozen coins
- Add URI support
- Fix fees in tx details
- Handle empty coins send
- Handle wallets in address book

* Merge main

* remove print [skip ci]

* Fix restore from QR

* minor improvement for QR restore

* minor fixes [skip ci]

* decred: Get slip44 addrs before sync completes. (#2092)

* - Fix loading wallet more than one time
- Fix minor UI issue

---------

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
Co-authored-by: JoeGruffins <34998433+JoeGruffins@users.noreply.github.com>
Co-authored-by: Wisdom Arerosuoghene <wisdom.arerosuoghene@gmail.com>
Co-authored-by: Philemon Ukane <ukanephilemon@gmail.com>
Co-authored-by: Czarek Nakamoto <cyjan@mrcyjanek.net>
This commit is contained in:
Omar Hatem
2025-03-21 04:18:47 +02:00
committed by GitHub
co-authored by JoeGruffins Wisdom Arerosuoghene Philemon Ukane Czarek Nakamoto
parent 52a39e29d4
commit 0ba54fa602
175 changed files with 7145 additions and 1115 deletions
@@ -306,6 +306,7 @@ abstract class BalanceViewModelBase with Store {
case WalletType.monero:
case WalletType.wownero:
case WalletType.zano:
case WalletType.decred:
return true;
default:
return false;
@@ -23,7 +23,6 @@ import 'package:cake_wallet/store/dashboard/trades_store.dart';
import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/store/yat/yat_store.dart';
import 'package:cake_wallet/utils/mobx.dart';
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
@@ -169,6 +168,9 @@ abstract class DashboardViewModelBase with Store {
type = appStore.wallet!.type,
transactions = ObservableList<TransactionListItem>(),
wallet = appStore.wallet! {
showDecredInfoCard = wallet.type == WalletType.decred &&
(sharedPreferences.getBool(PreferencesKey.showDecredInfoCard) ?? true);
name = wallet.name;
type = wallet.type;
isShowFirstYatIntroduction = false;
@@ -261,6 +263,7 @@ abstract class DashboardViewModelBase with Store {
reaction((_) => appStore.wallet, (wallet) {
_onWalletChange(wallet);
_checkMweb();
showDecredInfoCard = wallet?.type == WalletType.decred;
});
_transactionDisposer?.reaction.dispose();
@@ -350,6 +353,10 @@ abstract class DashboardViewModelBase with Store {
statusText = S.current.please_try_to_connect_to_another_node;
}
if (status is ProcessingSyncStatus) {
statusText = (status as ProcessingSyncStatus).message ?? S.current.processing;
}
return statusText;
}
@@ -399,13 +406,7 @@ abstract class DashboardViewModelBase with Store {
bool get isTestnet => wallet.type == WalletType.bitcoin && bitcoin!.isTestnet(wallet);
@computed
bool get hasRescan => [
WalletType.bitcoin,
WalletType.monero,
WalletType.litecoin,
WalletType.wownero,
WalletType.haven
].contains(wallet.type);
bool get hasRescan => wallet.hasRescan;
@computed
bool get isMoneroViewOnly {
@@ -490,6 +491,9 @@ abstract class DashboardViewModelBase with Store {
@observable
bool mwebEnabled = false;
@observable
late bool showDecredInfoCard;
@computed
bool get hasEnabledMwebBefore => settingsStore.hasEnabledMwebBefore;
@@ -543,6 +547,12 @@ abstract class DashboardViewModelBase with Store {
bitcoin!.setMwebEnabled(wallet, false);
}
@action
void dismissDecredInfoCard() {
showDecredInfoCard = false;
sharedPreferences.setBool(PreferencesKey.showDecredInfoCard, false);
}
BalanceViewModel balanceViewModel;
AppStore appStore;
@@ -573,6 +583,9 @@ abstract class DashboardViewModelBase with Store {
@computed
bool get isEnabledSwapAction => settingsStore.exchangeStatus != ExchangeApiMode.disabled;
@computed
bool get canSend => wallet.canSend();
@observable
bool hasSwapAction;
@@ -596,21 +609,28 @@ abstract class DashboardViewModelBase with Store {
@computed
bool get hasSignMessages {
if (wallet.isHardwareWallet) return false;
return [
WalletType.monero,
WalletType.litecoin,
WalletType.bitcoin,
WalletType.bitcoinCash,
WalletType.ethereum,
WalletType.polygon,
WalletType.solana,
WalletType.nano,
WalletType.banano,
WalletType.tron,
WalletType.wownero
].contains(wallet.type);
if (wallet.isHardwareWallet) {
return false;
}
switch (wallet.type) {
case WalletType.monero:
case WalletType.litecoin:
case WalletType.bitcoin:
case WalletType.bitcoinCash:
case WalletType.ethereum:
case WalletType.polygon:
case WalletType.solana:
case WalletType.nano:
case WalletType.banano:
case WalletType.tron:
case WalletType.wownero:
case WalletType.decred:
return true;
case WalletType.zano:
case WalletType.haven:
case WalletType.none:
return false;
}
}
bool get showRepWarning {
@@ -214,6 +214,7 @@ abstract class HomeSettingsViewModelBase with Store {
case WalletType.nano:
case WalletType.wownero:
case WalletType.bitcoinCash:
case WalletType.decred:
return false;
}
@@ -14,7 +14,9 @@ abstract class ReceiveOptionViewModelBase with Store {
(_wallet.type == WalletType.bitcoin ||
_wallet.type == WalletType.litecoin
? bitcoin!.getSelectedAddressType(_wallet)
: ReceivePageOption.mainnet),
: (_wallet.type == WalletType.decred && _wallet.isTestnet)
? ReceivePageOption.testnet
: ReceivePageOption.mainnet),
_options = [] {
final walletType = _wallet.type;
switch (walletType) {
@@ -33,6 +35,17 @@ abstract class ReceiveOptionViewModelBase with Store {
case WalletType.haven:
_options = [ReceivePageOption.mainnet];
break;
case WalletType.decred:
if (_wallet.isTestnet) {
_options = [
ReceivePageOption.testnet,
...ReceivePageOptions.where(
(element) => element != ReceivePageOption.mainnet)
];
} else {
_options = ReceivePageOptions;
}
break;
default:
_options = ReceivePageOptions;
}
@@ -1,3 +1,4 @@
import 'package:cake_wallet/decred/decred.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
@@ -82,7 +83,9 @@ class TransactionListItem extends ActionListItem with Keyable {
if (transaction.confirmations <= 0) {
str = S.current.pending;
}
if ((isPegOut || fromPegOut) && transaction.confirmations >= 0 && transaction.confirmations < 6) {
if ((isPegOut || fromPegOut) &&
transaction.confirmations >= 0 &&
transaction.confirmations < 6) {
str = " (${transaction.confirmations}/6)";
}
if (isPegIn) {
@@ -224,7 +227,13 @@ class TransactionListItem extends ActionListItem with Keyable {
cryptoAmount: zano!.formatterIntAmountToDouble(amount: transaction.amount, currency: asset, forFee: false),
price: price);
break;
default:
case WalletType.decred:
amount = calculateFiatAmountRaw(
cryptoAmount: decred!.formatterDecredAmountToDouble(amount: transaction.amount),
price: price);
break;
case WalletType.none:
case WalletType.banano:
break;
}