mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* feat: bitcoin view-only * fix: add UR to cw_bitcoin, fix payjoin issue * feat: add unsignedPsbt to PendingBitcoinTransaction * wip * feat: xpub restore from bitcoin URI QR * feat(dev): debug UR codes [skip ci] * fix: master fingerprint default in create bitcoin transaction * fix: handle empty private key in bitcoin transaction building * fix: show success dialog after btc ur transaction * fix(ui): remove SP from UI in view only wallet * fix(cw_bitcoin): tx sending on non-airgap * fix(cw_bitcoin): disable all non-segwit addresses * feat(ur): support BBQR for coldcard qr * flutter 3.27.0 -> 3.27.4 * feat: raw xpub qr support for coldcard q * fix: update ledger_bitcoin fix: update switching button * fix: restore button not showing up after scanning * feat: commit raw tx (from coldcard Q) * feat: legacy crypto-psbt support for seed signer * chore: address comments from review * fix(cw_bitcoin): disable sp and payjoin for cupcake * feat: enable DNSSEC BIP353 in PSBT (#2397) * feat: enable DNSSEC BIP353 in PSBT * chore: put bitcoin view only behind a featureflag * fix: update Monero wallet to work with new internal URQR return format * feat: add "Restore from Cupcake App" option with localized strings * feat: enable DNSSEC BIP353 in PSBT using dnssec-prover (#2401) * fix: use dnssec-prover chore: bump ndk to r28c * fix: validate DNSSEC proof before updating the UI * fix: rename button to copy debug info to not hide actions on URQR widget --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
87 lines
2.7 KiB
Dart
87 lines
2.7 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:cake_wallet/view_model/restore/restore_mode.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
class RestoredWallet {
|
|
RestoredWallet(
|
|
{required this.restoreMode,
|
|
required this.type,
|
|
required this.address,
|
|
this.txId,
|
|
this.spendKey,
|
|
this.viewKey,
|
|
this.mnemonicSeed,
|
|
this.passphrase,
|
|
this.txAmount,
|
|
this.txDescription,
|
|
this.recipientName,
|
|
this.height,
|
|
this.privateKey});
|
|
|
|
final WalletRestoreMode restoreMode;
|
|
final WalletType type;
|
|
final String? address;
|
|
final String? txId;
|
|
final String? spendKey;
|
|
final String? viewKey;
|
|
final String? mnemonicSeed;
|
|
final String? passphrase;
|
|
final String? txAmount;
|
|
final String? txDescription;
|
|
final String? recipientName;
|
|
final int? height;
|
|
final String? privateKey;
|
|
|
|
factory RestoredWallet.fromKey(Map<String, dynamic> json) {
|
|
try {
|
|
final codeParsed = jsonDecode(json['raw_qr'].toString());
|
|
if (codeParsed["version"] == 0) {
|
|
json['address'] = codeParsed["primaryAddress"];
|
|
json['view_key'] = codeParsed["privateViewKey"];
|
|
json['height'] = codeParsed["restoreHeight"].toString();
|
|
}
|
|
} catch (e) {
|
|
// fine, we don't care, it is only for monero anyway
|
|
}
|
|
json['view_key'] ??= json['xpub'];
|
|
final height = json['height'] as String?;
|
|
return RestoredWallet(
|
|
restoreMode: json['mode'] as WalletRestoreMode,
|
|
type: json['type'] as WalletType,
|
|
address: json['address'] as String?,
|
|
spendKey: json['spend_key'] as String?,
|
|
viewKey: json['view_key'] as String?,
|
|
height: height != null ? int.tryParse(height) ?? 0 : 0,
|
|
privateKey: json['private_key'] as String?,
|
|
);
|
|
}
|
|
|
|
factory RestoredWallet.fromSeed(Map<String, dynamic> json) {
|
|
final height = json['height'] as String?;
|
|
final mnemonic_seed = json['mnemonic_seed'] as String?;
|
|
final seed = json['seed'] as String? ?? json['hexSeed'] as String?;
|
|
final passphrase = json['passphrase'] as String?;
|
|
return RestoredWallet(
|
|
restoreMode: json['mode'] as WalletRestoreMode,
|
|
type: json['type'] as WalletType,
|
|
address: json['address'] as String?,
|
|
mnemonicSeed: mnemonic_seed ?? seed,
|
|
passphrase: passphrase,
|
|
height: height != null ? int.parse(height) : 0,
|
|
);
|
|
}
|
|
|
|
factory RestoredWallet.fromTxIds(Map<String, dynamic> json) {
|
|
return RestoredWallet(
|
|
restoreMode: json['mode'] as WalletRestoreMode,
|
|
type: json['type'] as WalletType,
|
|
address: json['address'] as String?,
|
|
txId: json['tx_payment_id'] as String,
|
|
txAmount: json['tx_amount'] as String,
|
|
txDescription: json['tx_description'] as String?,
|
|
recipientName: json['recipient_name'] as String?,
|
|
);
|
|
}
|
|
}
|