mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
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:
parent
52a39e29d4
commit
0ba54fa602
175 changed files with 7145 additions and 1115 deletions
|
@ -11,6 +11,7 @@ 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 walletTypesPath = 'lib/wallet_types.g.dart';
|
||||
const secureStoragePath = 'lib/core/secure_storage.dart';
|
||||
const pubspecDefaultPath = 'pubspec_default.yaml';
|
||||
|
@ -30,6 +31,7 @@ Future<void> main(List<String> args) async {
|
|||
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 excludeFlutterSecureStorage = args.contains('${prefix}excludeFlutterSecureStorage');
|
||||
|
||||
await generateBitcoin(hasBitcoin);
|
||||
|
@ -44,6 +46,7 @@ Future<void> main(List<String> args) async {
|
|||
await generateWownero(hasWownero);
|
||||
await generateZano(hasZano);
|
||||
// await generateBanano(hasEthereum);
|
||||
await generateDecred(hasDecred);
|
||||
|
||||
await generatePubspec(
|
||||
hasMonero: hasMonero,
|
||||
|
@ -59,6 +62,7 @@ Future<void> main(List<String> args) async {
|
|||
hasTron: hasTron,
|
||||
hasWownero: hasWownero,
|
||||
hasZano: hasZano,
|
||||
hasDecred: hasDecred,
|
||||
);
|
||||
await generateWalletTypes(
|
||||
hasMonero: hasMonero,
|
||||
|
@ -73,6 +77,7 @@ Future<void> main(List<String> args) async {
|
|||
hasTron: hasTron,
|
||||
hasWownero: hasWownero,
|
||||
hasZano: hasZano,
|
||||
hasDecred: hasDecred,
|
||||
);
|
||||
await injectSecureStorage(!excludeFlutterSecureStorage);
|
||||
}
|
||||
|
@ -1093,12 +1098,15 @@ abstract class BitcoinCash {
|
|||
""";
|
||||
|
||||
const bitcoinCashEmptyDefinition = 'BitcoinCash? bitcoinCash;\n';
|
||||
const bitcoinCashCWDefinition = 'BitcoinCash? bitcoinCash = CWBitcoinCash();\n';
|
||||
const bitcoinCashCWDefinition =
|
||||
'BitcoinCash? bitcoinCash = CWBitcoinCash();\n';
|
||||
|
||||
final output = '$bitcoinCashCommonHeaders\n' +
|
||||
(hasImplementation ? '$bitcoinCashCWHeaders\n' : '\n') +
|
||||
(hasImplementation ? '$bitcoinCashCwPart\n\n' : '\n') +
|
||||
(hasImplementation ? bitcoinCashCWDefinition : bitcoinCashEmptyDefinition) +
|
||||
(hasImplementation
|
||||
? bitcoinCashCWDefinition
|
||||
: bitcoinCashEmptyDefinition) +
|
||||
'\n' +
|
||||
bitcoinCashContent;
|
||||
|
||||
|
@ -1233,7 +1241,8 @@ abstract class NanoUtil {
|
|||
""";
|
||||
|
||||
const nanoEmptyDefinition = 'Nano? nano;\nNanoUtil? nanoUtil;\n';
|
||||
const nanoCWDefinition = 'Nano? nano = CWNano();\nNanoUtil? nanoUtil = CWNanoUtil();\n';
|
||||
const nanoCWDefinition =
|
||||
'Nano? nano = CWNano();\nNanoUtil? nanoUtil = CWNanoUtil();\n';
|
||||
|
||||
final output = '$nanoCommonHeaders\n' +
|
||||
(hasImplementation ? '$nanoCWHeaders\n' : '\n') +
|
||||
|
@ -1482,6 +1491,85 @@ abstract class Zano {
|
|||
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<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
|
||||
|
||||
List<TransactionPriority> getTransactionPriorities();
|
||||
TransactionPriority getDecredTransactionPriorityMedium();
|
||||
TransactionPriority getDecredTransactionPrioritySlow();
|
||||
TransactionPriority deserializeDecredTransactionPriority(int raw);
|
||||
|
||||
Object createDecredTransactionCredentials(List<Output> outputs, TransactionPriority priority);
|
||||
|
||||
List<AddressInfo> 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> generatePubspec({
|
||||
required bool hasMonero,
|
||||
required bool hasBitcoin,
|
||||
|
@ -1496,6 +1584,7 @@ Future<void> generatePubspec({
|
|||
required bool hasTron,
|
||||
required bool hasWownero,
|
||||
required bool hasZano,
|
||||
required bool hasDecred,
|
||||
}) async {
|
||||
const cwCore = """
|
||||
cw_core:
|
||||
|
@ -1564,6 +1653,10 @@ Future<void> generatePubspec({
|
|||
cw_zano:
|
||||
path: ./cw_zano
|
||||
""";
|
||||
const cwDecred = """
|
||||
cw_decred:
|
||||
path: ./cw_decred
|
||||
""";
|
||||
final inputFile = File(pubspecOutputPath);
|
||||
final inputText = await inputFile.readAsString();
|
||||
final inputLines = inputText.split('\n');
|
||||
|
@ -1613,6 +1706,10 @@ Future<void> generatePubspec({
|
|||
output += '\n$cwSharedExternal\n$cwHaven';
|
||||
}
|
||||
|
||||
if (hasDecred) {
|
||||
output += '\n$cwDecred';
|
||||
}
|
||||
|
||||
if (hasFlutterSecureStorage) {
|
||||
output += '\n$flutterSecureStorage\n';
|
||||
}
|
||||
|
@ -1654,6 +1751,7 @@ Future<void> generateWalletTypes({
|
|||
required bool hasTron,
|
||||
required bool hasWownero,
|
||||
required bool hasZano,
|
||||
required bool hasDecred,
|
||||
}) async {
|
||||
final walletTypesFile = File(walletTypesPath);
|
||||
|
||||
|
@ -1709,6 +1807,10 @@ Future<void> generateWalletTypes({
|
|||
outputContent += '\tWalletType.banano,\n';
|
||||
}
|
||||
|
||||
if (hasDecred) {
|
||||
outputContent += '\tWalletType.decred,\n';
|
||||
}
|
||||
|
||||
if (hasWownero) {
|
||||
outputContent += '\tWalletType.wownero,\n';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue