Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cw_decred/lib/api/libdcrwallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Libwallet {
final cName = name.toCString();
final cSignReq = signReq.toCString();
res = executePayloadFn(
fn: () => dcrwalletApi.createSignedTransaction(cName, cSignReq),
fn: () => dcrwalletApi.createTransaction(cName, cSignReq),
ptrsToFree: [cName, cSignReq],
);
break;
Expand Down
4 changes: 2 additions & 2 deletions cw_decred/lib/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ abstract class DecredWalletBase
"feerate": creds.feeRate ?? defaultFeeRate,
"password": _password,
"sendall": sendAll,
"sign": true,
};
final res = await _libwallet.createSignedTransaction(walletInfo.name, jsonEncode(signReq));
final decoded = json.decode(res);
final signedHex = decoded["signedhex"];

final signedHex = decoded["hex"];
final send = () async {
await _libwallet.sendRawTransaction(walletInfo.name, signedHex);
await updateBalance();
Expand Down
8 changes: 5 additions & 3 deletions cw_decred/lib/wallet_creation_credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/hardware/hardware_account_data.dart';

class DecredNewWalletCredentials extends WalletCredentials {
DecredNewWalletCredentials({required String name, WalletInfo? walletInfo})
: super(name: name, walletInfo: walletInfo);
DecredNewWalletCredentials(
{required String name, String? password, String? passphrase, WalletInfo? walletInfo})
: super(name: name, password: password, passphrase: passphrase, walletInfo: walletInfo);
}

class DecredRestoreWalletFromSeedCredentials extends WalletCredentials {
DecredRestoreWalletFromSeedCredentials(
{required String name,
required String password,
required this.mnemonic,
String? passphrase,
WalletInfo? walletInfo})
: super(name: name, password: password, walletInfo: walletInfo);
: super(name: name, password: password, passphrase: passphrase, walletInfo: walletInfo);

final String mnemonic;
}
Expand Down
7 changes: 7 additions & 0 deletions cw_decred/lib/wallet_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:bip39/bip39.dart' as bip39;
import 'package:cw_decred/api/libdcrwallet.dart';
import 'package:cw_decred/wallet_creation_credentials.dart';
import 'package:cw_decred/wallet.dart';
Expand Down Expand Up @@ -58,10 +59,15 @@ class DecredWalletService extends WalletService<
await this.init();
final dirPath = await pathForWalletDir(name: credentials.walletInfo!.name, type: getType());
final network = isTestnet == true ? testnet : mainnet;
final strength = credentials.seedPhraseLength == 24 ? 256 : 128;
final mnemonic = bip39.generateMnemonic(strength: strength);
final config = {
"name": credentials.walletInfo!.name,
"datadir": dirPath,
"pass": credentials.password!,
"mnemonic": mnemonic,
"seedpass": credentials.passphrase ?? "",
"birthday": DateTime.now().millisecondsSinceEpoch ~/ 1000,
"net": network,
"unsyncedaddrs": true,
};
Expand Down Expand Up @@ -209,6 +215,7 @@ class DecredWalletService extends WalletService<
"datadir": dirPath,
"pass": credentials.password!,
"mnemonic": credentials.mnemonic,
"seedpass": credentials.passphrase ?? "",
"net": network,
"unsyncedaddrs": true,
};
Expand Down
16 changes: 16 additions & 0 deletions cw_decred/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ packages:
url: "https://github.com/cake-tech/bech32.git"
source: git
version: "0.2.2"
bip39:
dependency: "direct main"
description:
name: bip39
sha256: de1ee27ebe7d96b84bb3a04a4132a0a3007dcdd5ad27dd14aa87a29d97c45edc
url: "https://pub.dev"
source: hosted
version: "1.0.6"
blockchain_utils:
dependency: transitive
description:
Expand Down Expand Up @@ -301,6 +309,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.2"
hex:
dependency: transitive
description:
name: hex
sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
hive:
dependency: "direct dev"
description:
Expand Down
1 change: 1 addition & 0 deletions cw_decred/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ environment:
dependencies:
flutter:
sdk: flutter
bip39: ^1.0.6
cw_core:
path: ../cw_core

Expand Down
2 changes: 1 addition & 1 deletion lib/core/wallet_creation_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ class WalletCreationService {
case WalletType.dogecoin:
case WalletType.nano:
case WalletType.zcash:
case WalletType.decred:
return true;
case WalletType.monero:
case WalletType.wownero:
case WalletType.none:
case WalletType.haven:
case WalletType.banano:
case WalletType.zano:
case WalletType.decred:
return false;
}
}
Expand Down
13 changes: 9 additions & 4 deletions lib/decred/cw_decred.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ class CWDecred extends Decred {

@override
WalletCredentials createDecredNewWalletCredentials(
{required String name, WalletInfo? walletInfo}) =>
DecredNewWalletCredentials(name: name, walletInfo: walletInfo);
{required String name, String? password, String? passphrase, WalletInfo? walletInfo}) =>
DecredNewWalletCredentials(
name: name, password: password, passphrase: passphrase, walletInfo: walletInfo);

@override
WalletCredentials createDecredRestoreWalletFromSeedCredentials(
{required String name, required String mnemonic, required String password}) =>
DecredRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password);
{required String name,
required String mnemonic,
required String password,
String? passphrase}) =>
DecredRestoreWalletFromSeedCredentials(
name: name, mnemonic: mnemonic, password: password, passphrase: passphrase);

@override
WalletCredentials createDecredRestoreWalletFromPubkeyCredentials(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/screens/restore/wallet_restore_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ class _WalletRestorePageBodyState extends State<_WalletRestorePageBody>
}

if ((walletRestoreViewModel.type == WalletType.decred) &&
seedWords.length != WalletRestoreViewModelBase.decredSeedMnemonicLength) {
![12, 15, 24].contains(seedWords.length)) {
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/view_model/advanced_privacy_settings_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
case WalletType.solana:
case WalletType.tron:
case WalletType.zcash:
case WalletType.decred:
return true;

case WalletType.bitcoin:
Expand All @@ -74,7 +75,6 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
case WalletType.none:
case WalletType.haven:
case WalletType.zano:
case WalletType.decred:
return false;
}
}
Expand Down Expand Up @@ -107,7 +107,8 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
WalletType.zano,
WalletType.dogecoin,
WalletType.zcash,
].contains(type);
WalletType.decred,
].contains(type);

@computed
bool get addCustomNode => _addCustomNode;
Expand Down
3 changes: 2 additions & 1 deletion lib/view_model/wallet_new_vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
passphrase: passphrase,
);
case WalletType.decred:
return decred!.createDecredNewWalletCredentials(name: name);
return decred!.createDecredNewWalletCredentials(
name: name, password: walletPassword, passphrase: passphrase);
case WalletType.none:
case WalletType.haven:
throw Exception('Unexpected type: ${type.toString()}');
Expand Down
1 change: 1 addition & 0 deletions lib/view_model/wallet_restore_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
name: name,
mnemonic: seed,
password: password,
passphrase: passphrase,
);
case WalletType.zcash:
return zcash!.createZcashRestoreWalletFromSeedCredentials(
Expand Down
2 changes: 1 addition & 1 deletion scripts/android/build_decred.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd "$(dirname "$0")"
CW_DECRED_DIR=$(realpath ../..)/cw_decred
LIBWALLET_PATH="${PWD}/decred/libwallet"
LIBWALLET_URL="https://github.com/decred/libwallet.git"
LIBWALLET_VERSION="05f8d7374999400fe4d525eb365c39b77d307b14"
LIBWALLET_VERSION="ecc4a5fb9594368777848de42d7e072d62406507"

if [[ -e $LIBWALLET_PATH ]]; then
rm -fr $LIBWALLET_PATH || true
Expand Down
2 changes: 1 addition & 1 deletion scripts/ios/build_decred.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
. ./config.sh
LIBWALLET_PATH="${EXTERNAL_IOS_SOURCE_DIR}/libwallet"
LIBWALLET_URL="https://github.com/decred/libwallet.git"
LIBWALLET_VERSION="05f8d7374999400fe4d525eb365c39b77d307b14"
LIBWALLET_VERSION="ecc4a5fb9594368777848de42d7e072d62406507"

if [[ -e $LIBWALLET_PATH ]]; then
rm -fr $LIBWALLET_PATH
Expand Down
4 changes: 2 additions & 2 deletions tool/configure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,9 @@ import 'package:cw_decred/mnemonic.dart';

abstract class Decred {
WalletCredentials createDecredNewWalletCredentials(
{required String name, WalletInfo? walletInfo});
{required String name, String? password, String? passphrase, WalletInfo? walletInfo});
WalletCredentials createDecredRestoreWalletFromSeedCredentials(
{required String name, required String mnemonic, required String password});
{required String name, required String mnemonic, required String password, String? passphrase});
WalletCredentials createDecredRestoreWalletFromPubkeyCredentials(
{required String name, required String pubkey, required String password});
WalletService createDecredWalletService(Box<UnspentCoinsInfo> unspentCoinSource);
Expand Down
Loading