Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decred #1938

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1c3d6f8
decred: Add decred. (#1322)
JoeGruffins Jan 5, 2025
5f06af1
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Jan 5, 2025
1f0cc5b
fix extracted addresses not used
OmarHatem28 Jan 5, 2025
64bf965
remove print [skip ci]
OmarHatem28 Jan 5, 2025
f6b2c39
minor formatting
OmarHatem28 Jan 5, 2025
ad1f91c
fix initial migration version
OmarHatem28 Jan 5, 2025
cb8f83e
add build decred script to workflow
OmarHatem28 Jan 5, 2025
fd294e8
install go before build decred
OmarHatem28 Jan 5, 2025
8f5c6b4
trial 2 to fix decred build
OmarHatem28 Jan 5, 2025
8c81ec3
re-install go
OmarHatem28 Jan 6, 2025
cf6268f
revert build script change
OmarHatem28 Jan 6, 2025
b6e0762
refactor/clean nodes functions
OmarHatem28 Jan 6, 2025
baefdf8
Fix address book issue
OmarHatem28 Jan 7, 2025
8511899
Fix transactions display issues
OmarHatem28 Jan 7, 2025
12dd315
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Jan 14, 2025
3f9e97f
Fix unconfirmed balance not displayed
OmarHatem28 Jan 15, 2025
0bf742a
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Jan 15, 2025
d52e087
Fix workflow
OmarHatem28 Jan 15, 2025
3d139bd
Fix workflow
OmarHatem28 Jan 15, 2025
a6bc2f8
Fix workflow
OmarHatem28 Jan 15, 2025
642a521
test
OmarHatem28 Jan 15, 2025
f2c0073
hardcode path for now
OmarHatem28 Jan 15, 2025
1da7683
fix + cleanup decred build script to work on mac and linux
MrCyjaneK Jan 16, 2025
6f6d005
Update decred build script
MrCyjaneK Jan 16, 2025
d5e05ef
Run actions on pull requests, extract commit message
MrCyjaneK Jan 16, 2025
8e16038
run after checkout
MrCyjaneK Jan 16, 2025
a730729
add safe directory
MrCyjaneK Jan 16, 2025
a02603e
Get commit message from base.sha instead of last commit
MrCyjaneK Jan 16, 2025
7c14ed2
base -> head
MrCyjaneK Jan 16, 2025
f91ef64
Do not merge main branch into pr
MrCyjaneK Jan 16, 2025
db06792
[skip slack] [run tests] clone by sha
MrCyjaneK Jan 16, 2025
b5a6837
Proper name for decred library in the build script
MrCyjaneK Jan 16, 2025
243bc9f
Throw an error when ANDROID_HOME or ANDROID_NDK_VERSION is missing
MrCyjaneK Jan 18, 2025
d8fb146
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Jan 30, 2025
8591396
Fix conflicts with main
OmarHatem28 Jan 30, 2025
473d2ce
minor code enhancement
OmarHatem28 Jan 30, 2025
60d05af
decred: Add used address history. (#1941)
JoeGruffins Feb 5, 2025
47b6922
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Feb 5, 2025
c9d55cf
minor fixes and cleanup
OmarHatem28 Feb 5, 2025
c9aa1c5
minor fix, feel free to test now
OmarHatem28 Feb 5, 2025
28752a6
- Fix transaction details
OmarHatem28 Feb 6, 2025
85d5a9e
Add decred info card
OmarHatem28 Feb 10, 2025
ee64bc1
push missing file
OmarHatem28 Feb 10, 2025
fb54322
Add missing text for decred info card
OmarHatem28 Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/no_print_in_dart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: No print statements in dart files

on:
pull_request:
branches: [main]
on: [pull_request]

jobs:
PR_test_build:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/pr_test_build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
echo "message<<EOF" >> $GITHUB_ENV
echo "$FULL_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Add secrets
run: |
touch lib/.secrets.g.dart
Expand Down Expand Up @@ -241,6 +242,13 @@ jobs:
./build_mwebd.sh --dont-install
popd

- name: Build Decred
run: |
set -x -e
pushd scripts/android
./build_decred.sh
popd

- name: Build generated code
run: |
./model_generator.sh async
Expand Down Expand Up @@ -281,7 +289,7 @@ jobs:
set -x
apk_file=$(ls build/app/outputs/flutter-apk/test-apk/*_slack.apk || exit 1)
echo "APK_FILE=$apk_file" >> $GITHUB_ENV

- name: Upload artifact to slack
if: ${{ !contains(env.message, 'skip slack') }}
continue-on-error: true
Expand All @@ -294,7 +302,7 @@ jobs:

- name: cleanup
run: rm -rf build/app/outputs/flutter-apk/test-apk/

- name: Upload Artifact to github
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_test_build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: configure git
run: |
git config --global --add safe.directory '*'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.history
.svn/
.fvm/
.fvmrc

# IntelliJ related
*.iml
Expand Down Expand Up @@ -138,6 +139,7 @@ lib/solana/solana.dart
lib/tron/tron.dart
lib/wownero/wownero.dart
lib/zano/zano.dart
lib/decred/decred.dart

ios/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_180.png
ios/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_120.png
Expand Down Expand Up @@ -171,6 +173,7 @@ macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
macos/Runner/Configs/AppInfo.xcconfig
macos/Runner.xcodeproj/project.pbxproj


integration_test/playground.dart
Expand Down
6 changes: 6 additions & 0 deletions assets/decred_node_list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-
uri: default-spv-nodes
is_default: true
-
uri: dcrd.sethforprivacy.com:9108
useSSL: true
Binary file added assets/images/2.0x/decred.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2.0x/decred_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/decred.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/decred_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/dcr_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/decred.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/decred_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/decred_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions cw_bitcoin/lib/bitcoin_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
});
}

@override
bool get hasRescan => true;

static Future<BitcoinWallet> create({
required String mnemonic,
required String password,
Expand Down
4 changes: 3 additions & 1 deletion cw_bitcoin/lib/litecoin_wallet.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';

import 'package:convert/convert.dart' as convert;
import 'dart:math';
Expand Down Expand Up @@ -155,6 +154,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
@observable
SyncStatus mwebSyncStatus = NotConnectedSyncStatus();

@override
bool get hasRescan => true;

List<int> get scanSecret => mwebHd!.childKey(Bip32KeyIndex(0x80000000)).privateKey.privKey.raw;
List<int> get spendSecret => mwebHd!.childKey(Bip32KeyIndex(0x80000001)).privateKey.privKey.raw;

Expand Down
1 change: 1 addition & 0 deletions cw_core/lib/amount_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AmountConverter {
case CryptoCurrency.btc:
case CryptoCurrency.bch:
case CryptoCurrency.ltc:
case CryptoCurrency.dcr:
return _bitcoinAmountToString(amount);
case CryptoCurrency.xhv:
case CryptoCurrency.xag:
Expand Down
7 changes: 6 additions & 1 deletion cw_core/lib/currency_for_wallet_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ CryptoCurrency currencyForWalletType(WalletType type, {bool? isTestnet}) {
return CryptoCurrency.wow;
case WalletType.zano:
return CryptoCurrency.zano;
case WalletType.decred:
return CryptoCurrency.dcr;
case WalletType.none:
throw Exception(

'Unexpected wallet type: ${type.toString()} for CryptoCurrency currencyForWalletType');
}
}
Expand Down Expand Up @@ -65,6 +66,10 @@ WalletType? walletTypeForCurrency(CryptoCurrency currency) {
return WalletType.tron;
case CryptoCurrency.wow:
return WalletType.wownero;
case CryptoCurrency.zano:
return WalletType.zano;
case CryptoCurrency.dcr:
return WalletType.decred;
default:
return null;
}
Expand Down
18 changes: 18 additions & 0 deletions cw_core/lib/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class Node extends HiveObject with Keyable {
case WalletType.solana:
case WalletType.tron:
case WalletType.zano:
case WalletType.decred:
return Uri.parse(
"http${isSSL ? "s" : ""}://$uriRaw${path!.startsWith("/") || path!.isEmpty ? path : "/$path"}");
case WalletType.none:
Expand Down Expand Up @@ -167,6 +168,8 @@ class Node extends HiveObject with Keyable {
return requestElectrumServer();
case WalletType.zano:
return requestZanoNode();
case WalletType.decred:
return requestDecredNode();
case WalletType.none:
return false;
}
Expand Down Expand Up @@ -355,6 +358,21 @@ class Node extends HiveObject with Keyable {
return false;
}
}

Future<bool> requestDecredNode() async {
if (uri.host == "default-spv-nodes") {
// Just show default port as ok. The wallet will connect to a list of known
// nodes automatically.
return true;
}
try {
final socket = await Socket.connect(uri.host, uri.port, timeout: Duration(seconds: 5));
socket.destroy();
return true;
} catch (_) {
return false;
}
}
}

/// https://github.com/ManyMath/digest_auth/
Expand Down
1 change: 1 addition & 0 deletions cw_core/lib/receive_page_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:cw_core/enumerate.dart';

class ReceivePageOption implements Enumerate {
static const mainnet = ReceivePageOption._('mainnet');
static const testnet = ReceivePageOption._('testnet');
static const anonPayInvoice = ReceivePageOption._('anonPayInvoice');
static const anonPayDonationLink = ReceivePageOption._('anonPayDonationLink');

Expand Down
10 changes: 10 additions & 0 deletions cw_core/lib/sync_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class SyncingSyncStatus extends SyncStatus {
}
}

class ProcessingSyncStatus extends SyncStatus {
final String? message;

ProcessingSyncStatus({this.message});

@override
double progress() => 0.99;

}

class SyncedSyncStatus extends SyncStatus {
@override
double progress() => 1.0;
Expand Down
2 changes: 2 additions & 0 deletions cw_core/lib/wallet_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans

bool get isHardwareWallet => walletInfo.isHardwareWallet;

bool get hasRescan => false;

Future<void> connectToNode({required Node node});

// there is a default definition here because only coins with a pow node (nano based) need to override this
Expand Down
15 changes: 14 additions & 1 deletion cw_core/lib/wallet_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const walletTypes = [
WalletType.solana,
WalletType.tron,
WalletType.zano,
WalletType.decred,
];

@HiveType(typeId: WALLET_TYPE_TYPE_ID)
Expand Down Expand Up @@ -60,9 +61,11 @@ enum WalletType {
@HiveField(12)
wownero,

@HiveField(13)
@HiveField(13)
zano,

@HiveField(14)
decred
}

int serializeToInt(WalletType type) {
Expand Down Expand Up @@ -93,6 +96,8 @@ int serializeToInt(WalletType type) {
return 11;
case WalletType.zano:
return 12;
case WalletType.decred:
return 13;
case WalletType.none:
return -1;
}
Expand Down Expand Up @@ -126,6 +131,8 @@ WalletType deserializeFromInt(int raw) {
return WalletType.wownero;
case 12:
return WalletType.zano;
case 13:
return WalletType.decred;
default:
throw Exception(
'Unexpected token: $raw for WalletType deserializeFromInt');
Expand Down Expand Up @@ -160,6 +167,8 @@ String walletTypeToString(WalletType type) {
return 'Wownero';
case WalletType.zano:
return 'Zano';
case WalletType.decred:
return 'Decred';
case WalletType.none:
return '';
}
Expand Down Expand Up @@ -193,6 +202,8 @@ String walletTypeToDisplayName(WalletType type) {
return 'Wownero (WOW)';
case WalletType.zano:
return 'Zano (ZANO)';
case WalletType.decred:
return 'Decred (DCR)';
case WalletType.none:
return '';
}
Expand Down Expand Up @@ -229,6 +240,8 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type, {bool isTestnet = fal
return CryptoCurrency.wow;
case WalletType.zano:
return CryptoCurrency.zano;
case WalletType.decred:
return CryptoCurrency.dcr;
case WalletType.none:
throw Exception(
'Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency');
Expand Down
39 changes: 39 additions & 0 deletions cw_decred/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

android/.externalNativeBuild/
android/.cxx/
android/libs
ios/External/
macos/External/

*libdcrwallet.h
libdcrwallet_bindings.dart
36 changes: 36 additions & 0 deletions cw_decred/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
channel: unknown

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: android
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: ios
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: macos
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions cw_decred/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [0.0.1] - TODO: Add release date.

* TODO: Describe initial release.
1 change: 1 addition & 0 deletions cw_decred/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
3 changes: 3 additions & 0 deletions cw_decred/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cw_decred

TODO: Fill this out.
4 changes: 4 additions & 0 deletions cw_decred/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
9 changes: 9 additions & 0 deletions cw_decred/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx
Loading
Loading