mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-21 06:18:42 +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>
96 lines
2.8 KiB
Dart
96 lines
2.8 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:cw_monero/api/account_list.dart';
|
|
import 'package:cw_monero/api/structs/pending_transaction.dart';
|
|
import 'package:cw_monero/api/transaction_history.dart'
|
|
as monero_transaction_history;
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/amount_converter.dart';
|
|
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
import 'package:cw_monero/api/wallet.dart';
|
|
import 'package:cw_monero/monero_wallet.dart';
|
|
|
|
class DoubleSpendException implements Exception {
|
|
DoubleSpendException();
|
|
|
|
@override
|
|
String toString() =>
|
|
'This transaction cannot be committed. This can be due to many reasons including the wallet not being synced, there is not enough XMR in your available balance, or previous transactions are not yet fully processed.';
|
|
}
|
|
|
|
class PendingMoneroTransaction with PendingTransaction {
|
|
PendingMoneroTransaction(this.pendingTransactionDescription, this.wallet);
|
|
|
|
final PendingTransactionDescription pendingTransactionDescription;
|
|
final MoneroWalletBase wallet;
|
|
|
|
@override
|
|
String get id => pendingTransactionDescription.hash;
|
|
|
|
@override
|
|
String get hex => pendingTransactionDescription.hex;
|
|
|
|
@override
|
|
String get amountFormatted => AmountConverter.amountIntToString(
|
|
CryptoCurrency.xmr, pendingTransactionDescription.amount);
|
|
|
|
@override
|
|
String get feeFormatted => "$feeFormattedValue XMR";
|
|
|
|
@override
|
|
String get feeFormattedValue => AmountConverter.amountIntToString(
|
|
CryptoCurrency.xmr, pendingTransactionDescription.fee);
|
|
|
|
@override
|
|
bool shouldCommitUR() => isViewOnly;
|
|
|
|
@override
|
|
Future<void> commit() async {
|
|
try {
|
|
await monero_transaction_history.commitTransactionFromPointerAddress(
|
|
address: pendingTransactionDescription.pointerAddress,
|
|
useUR: false);
|
|
} catch (e) {
|
|
final message = e.toString();
|
|
|
|
if (message.contains('Reason: double spend')) {
|
|
throw DoubleSpendException();
|
|
}
|
|
|
|
rethrow;
|
|
}
|
|
storeSync(force: true);
|
|
unawaited(() async {
|
|
await Future.delayed(const Duration(milliseconds: 250));
|
|
await wallet.fetchTransactions();
|
|
}());
|
|
}
|
|
|
|
@override
|
|
Future<Map<String, String>> commitUR() async {
|
|
try {
|
|
final ret = await monero_transaction_history.commitTransactionFromPointerAddress(
|
|
address: pendingTransactionDescription.pointerAddress,
|
|
useUR: true);
|
|
storeSync(force: true);
|
|
unawaited(() async {
|
|
await Future.delayed(const Duration(milliseconds: 250));
|
|
await wallet.fetchTransactions();
|
|
}());
|
|
if (ret == null) return {};
|
|
return {
|
|
"xmr-txsigned": ret,
|
|
};
|
|
} catch (e) {
|
|
final message = e.toString();
|
|
|
|
if (message.contains('Reason: double spend')) {
|
|
throw DoubleSpendException();
|
|
}
|
|
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|