cake_wallet/cw_bitcoin/lib/bitcoin_transaction_priority.dart

296 lines
8.7 KiB
Dart
Raw Normal View History

import 'package:cw_core/transaction_priority.dart';
2024-11-06 15:06:52 +00:00
class BitcoinTransactionPriority extends TransactionPriority {
const BitcoinTransactionPriority({required super.title, required super.raw});
2024-10-28 15:16:23 +00:00
// Unimportant: the lowest possible, confirms when it confirms no matter how long it takes
2024-11-06 15:06:52 +00:00
static const BitcoinTransactionPriority unimportant =
BitcoinTransactionPriority(title: 'Unimportant', raw: 0);
2024-10-28 15:16:23 +00:00
// Normal: low fee, confirms in a reasonable time, normal because in most cases more than this is not needed, gets you in the next 2-3 blocks (about 1 hour)
2024-11-06 15:06:52 +00:00
static const BitcoinTransactionPriority normal =
BitcoinTransactionPriority(title: 'Normal', raw: 1);
2024-10-28 15:16:23 +00:00
// Elevated: medium fee, confirms soon, elevated because it's higher than normal, gets you in the next 1-2 blocks (about 30 mins)
2024-11-06 15:06:52 +00:00
static const BitcoinTransactionPriority elevated =
BitcoinTransactionPriority(title: 'Elevated', raw: 2);
2024-10-28 15:16:23 +00:00
// Priority: high fee, expected in the next block (about 10 mins).
2024-11-06 15:06:52 +00:00
static const BitcoinTransactionPriority priority =
BitcoinTransactionPriority(title: 'Priority', raw: 3);
// Custom: any fee, user defined
static const BitcoinTransactionPriority custom =
BitcoinTransactionPriority(title: 'Custom', raw: 4);
2024-10-28 15:16:23 +00:00
2024-11-06 15:06:52 +00:00
static BitcoinTransactionPriority deserialize({required int raw}) {
switch (raw) {
case 0:
2024-10-28 15:16:23 +00:00
return unimportant;
case 1:
2024-10-28 15:16:23 +00:00
return normal;
case 2:
2024-10-28 15:16:23 +00:00
return elevated;
Add rbf (#1323) * Add initial checkbox for RBF * minor progress * minor progress * Minor progress * Debugging RBF * Minor fix * Fix RBF transaction inputs (now it's working) * New versions Fix issues with Monero.com * Add sending for Solana tokens exchanges * Add default keyword for P2WPKH [skip ci] * chore: Switch solana commitment to confirmed to reduced blockhash expiration (#1313) * Modify test workflow to send arm64-v8a build only * Fix workflow build path * Remove unnecessary reverse of txId * Update Replace by fee with the new bitcoin base implementation * btc custom fee priority * add feeRate to btc credential * UI fixes * add check if the change covers the fee * Update settings_store.dart * add check confirmation for rbf * add a check to see if the change is sufficient for the new fee * addressing PR comments * update localization files * addressing PR comments * minor fixes * Update transaction_details_view_model.dart * Minor Fix for building Monero.com [skip ci] * update localization files * add bump fee page * update localisation files * Update cw_bitcoin.dart * fix merge conflict * fix UI issues * Fix Conflicts, Fix RBF flow, some enhancements * prevent default custom fee rate * hide outputs and inputs items * minor fix [skip ci] * addressing PR comments * remove rbf checkbox * default picker value * minor ui change [skip ci] * min fee rate [skip ci] * Minor fix and some minor enhancements --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
2024-04-08 14:54:58 +00:00
case 3:
2024-10-28 15:16:23 +00:00
return priority;
case 4:
Add rbf (#1323) * Add initial checkbox for RBF * minor progress * minor progress * Minor progress * Debugging RBF * Minor fix * Fix RBF transaction inputs (now it's working) * New versions Fix issues with Monero.com * Add sending for Solana tokens exchanges * Add default keyword for P2WPKH [skip ci] * chore: Switch solana commitment to confirmed to reduced blockhash expiration (#1313) * Modify test workflow to send arm64-v8a build only * Fix workflow build path * Remove unnecessary reverse of txId * Update Replace by fee with the new bitcoin base implementation * btc custom fee priority * add feeRate to btc credential * UI fixes * add check if the change covers the fee * Update settings_store.dart * add check confirmation for rbf * add a check to see if the change is sufficient for the new fee * addressing PR comments * update localization files * addressing PR comments * minor fixes * Update transaction_details_view_model.dart * Minor Fix for building Monero.com [skip ci] * update localization files * add bump fee page * update localisation files * Update cw_bitcoin.dart * fix merge conflict * fix UI issues * Fix Conflicts, Fix RBF flow, some enhancements * prevent default custom fee rate * hide outputs and inputs items * minor fix [skip ci] * addressing PR comments * remove rbf checkbox * default picker value * minor ui change [skip ci] * min fee rate [skip ci] * Minor fix and some minor enhancements --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
2024-04-08 14:54:58 +00:00
return custom;
default:
2024-10-28 15:16:23 +00:00
throw Exception('Unexpected token: $raw for TransactionPriority deserialize');
}
}
@override
String toString() {
var label = '';
switch (this) {
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.unimportant:
2024-10-28 15:16:23 +00:00
label = 'Unimportant ~24hrs+'; // '${S.current.transaction_priority_slow} ~24hrs';
break;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.normal:
2024-10-28 15:16:23 +00:00
label = 'Normal ~1hr+'; // S.current.transaction_priority_medium;
break;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.elevated:
2024-10-28 15:16:23 +00:00
label = 'Elevated';
break; // S.current.transaction_priority_fast;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.priority:
2024-10-28 15:16:23 +00:00
label = 'Priority';
Add rbf (#1323) * Add initial checkbox for RBF * minor progress * minor progress * Minor progress * Debugging RBF * Minor fix * Fix RBF transaction inputs (now it's working) * New versions Fix issues with Monero.com * Add sending for Solana tokens exchanges * Add default keyword for P2WPKH [skip ci] * chore: Switch solana commitment to confirmed to reduced blockhash expiration (#1313) * Modify test workflow to send arm64-v8a build only * Fix workflow build path * Remove unnecessary reverse of txId * Update Replace by fee with the new bitcoin base implementation * btc custom fee priority * add feeRate to btc credential * UI fixes * add check if the change covers the fee * Update settings_store.dart * add check confirmation for rbf * add a check to see if the change is sufficient for the new fee * addressing PR comments * update localization files * addressing PR comments * minor fixes * Update transaction_details_view_model.dart * Minor Fix for building Monero.com [skip ci] * update localization files * add bump fee page * update localisation files * Update cw_bitcoin.dart * fix merge conflict * fix UI issues * Fix Conflicts, Fix RBF flow, some enhancements * prevent default custom fee rate * hide outputs and inputs items * minor fix [skip ci] * addressing PR comments * remove rbf checkbox * default picker value * minor ui change [skip ci] * min fee rate [skip ci] * Minor fix and some minor enhancements --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
2024-04-08 14:54:58 +00:00
break; // S.current.transaction_priority_fast;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.custom:
Add rbf (#1323) * Add initial checkbox for RBF * minor progress * minor progress * Minor progress * Debugging RBF * Minor fix * Fix RBF transaction inputs (now it's working) * New versions Fix issues with Monero.com * Add sending for Solana tokens exchanges * Add default keyword for P2WPKH [skip ci] * chore: Switch solana commitment to confirmed to reduced blockhash expiration (#1313) * Modify test workflow to send arm64-v8a build only * Fix workflow build path * Remove unnecessary reverse of txId * Update Replace by fee with the new bitcoin base implementation * btc custom fee priority * add feeRate to btc credential * UI fixes * add check if the change covers the fee * Update settings_store.dart * add check confirmation for rbf * add a check to see if the change is sufficient for the new fee * addressing PR comments * update localization files * addressing PR comments * minor fixes * Update transaction_details_view_model.dart * Minor Fix for building Monero.com [skip ci] * update localization files * add bump fee page * update localisation files * Update cw_bitcoin.dart * fix merge conflict * fix UI issues * Fix Conflicts, Fix RBF flow, some enhancements * prevent default custom fee rate * hide outputs and inputs items * minor fix [skip ci] * addressing PR comments * remove rbf checkbox * default picker value * minor ui change [skip ci] * min fee rate [skip ci] * Minor fix and some minor enhancements --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
2024-04-08 14:54:58 +00:00
label = 'Custom';
break;
default:
break;
}
return label;
}
Add rbf (#1323) * Add initial checkbox for RBF * minor progress * minor progress * Minor progress * Debugging RBF * Minor fix * Fix RBF transaction inputs (now it's working) * New versions Fix issues with Monero.com * Add sending for Solana tokens exchanges * Add default keyword for P2WPKH [skip ci] * chore: Switch solana commitment to confirmed to reduced blockhash expiration (#1313) * Modify test workflow to send arm64-v8a build only * Fix workflow build path * Remove unnecessary reverse of txId * Update Replace by fee with the new bitcoin base implementation * btc custom fee priority * add feeRate to btc credential * UI fixes * add check if the change covers the fee * Update settings_store.dart * add check confirmation for rbf * add a check to see if the change is sufficient for the new fee * addressing PR comments * update localization files * addressing PR comments * minor fixes * Update transaction_details_view_model.dart * Minor Fix for building Monero.com [skip ci] * update localization files * add bump fee page * update localisation files * Update cw_bitcoin.dart * fix merge conflict * fix UI issues * Fix Conflicts, Fix RBF flow, some enhancements * prevent default custom fee rate * hide outputs and inputs items * minor fix [skip ci] * addressing PR comments * remove rbf checkbox * default picker value * minor ui change [skip ci] * min fee rate [skip ci] * Minor fix and some minor enhancements --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
2024-04-08 14:54:58 +00:00
String labelWithRate(int rate, int? customRate) {
final rateValue = this == custom ? customRate ??= 0 : rate;
return '${toString()} ($rateValue ${units}/byte)';
}
}
2024-11-06 15:06:52 +00:00
class ElectrumTransactionPriority extends TransactionPriority {
const ElectrumTransactionPriority({required String title, required int raw})
: super(title: title, raw: raw);
2024-11-06 15:06:52 +00:00
static const List<ElectrumTransactionPriority> all = [fast, medium, slow, custom];
static const ElectrumTransactionPriority slow =
ElectrumTransactionPriority(title: 'Slow', raw: 0);
static const ElectrumTransactionPriority medium =
ElectrumTransactionPriority(title: 'Medium', raw: 1);
static const ElectrumTransactionPriority fast =
ElectrumTransactionPriority(title: 'Fast', raw: 2);
static const ElectrumTransactionPriority custom =
ElectrumTransactionPriority(title: 'Custom', raw: 3);
static ElectrumTransactionPriority deserialize({required int raw}) {
switch (raw) {
case 0:
2024-11-06 15:06:52 +00:00
return slow;
case 1:
2024-11-06 15:06:52 +00:00
return medium;
case 2:
2024-11-06 15:06:52 +00:00
return fast;
2024-10-28 15:16:23 +00:00
case 3:
return custom;
default:
2024-11-06 15:06:52 +00:00
throw Exception('Unexpected token: $raw for ElectrumTransactionPriority deserialize');
}
}
2024-11-06 15:06:52 +00:00
String get units => 'sat';
@override
String toString() {
var label = '';
switch (this) {
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.slow:
2024-10-28 15:16:23 +00:00
label = 'Slow ~24hrs+'; // '${S.current.transaction_priority_slow} ~24hrs';
break;
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.medium:
2024-10-28 15:16:23 +00:00
label = 'Medium'; // S.current.transaction_priority_medium;
2024-11-06 15:06:52 +00:00
break;
case ElectrumTransactionPriority.fast:
2024-10-28 15:16:23 +00:00
label = 'Fast';
break; // S.current.transaction_priority_fast;
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.custom:
2024-10-28 15:16:23 +00:00
label = 'Custom';
break;
default:
break;
}
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
return label;
}
2024-10-28 15:16:23 +00:00
String labelWithRate(int rate, int? customRate) {
final rateValue = this == custom ? customRate ??= 0 : rate;
return '${toString()} ($rateValue ${units}/byte)';
}
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
}
2024-11-06 15:06:52 +00:00
class LitecoinTransactionPriority extends ElectrumTransactionPriority {
2024-10-28 15:16:23 +00:00
const LitecoinTransactionPriority({required super.title, required super.raw});
@override
String get units => 'lit';
}
2024-11-06 15:06:52 +00:00
class BitcoinCashTransactionPriority extends ElectrumTransactionPriority {
2024-10-28 15:16:23 +00:00
const BitcoinCashTransactionPriority({required super.title, required super.raw});
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
@override
2024-10-28 15:16:23 +00:00
String get units => 'satoshi';
}
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
2024-11-06 15:06:52 +00:00
class BitcoinTransactionPriorities implements TransactionPriorities {
const BitcoinTransactionPriorities({
2024-10-28 15:16:23 +00:00
required this.unimportant,
required this.normal,
required this.elevated,
required this.priority,
2024-11-06 15:06:52 +00:00
required this.custom,
2024-10-28 15:16:23 +00:00
});
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
2024-10-28 15:16:23 +00:00
final int unimportant;
final int normal;
final int elevated;
final int priority;
2024-11-06 15:06:52 +00:00
final int custom;
2024-10-28 15:16:23 +00:00
@override
int operator [](TransactionPriority type) {
switch (type) {
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.unimportant:
2024-10-28 15:16:23 +00:00
return unimportant;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.normal:
2024-10-28 15:16:23 +00:00
return normal;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.elevated:
2024-10-28 15:16:23 +00:00
return elevated;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.priority:
2024-10-28 15:16:23 +00:00
return priority;
2024-11-06 15:06:52 +00:00
case BitcoinTransactionPriority.custom:
return custom;
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
default:
2024-10-28 15:16:23 +00:00
throw Exception('Unexpected token: $type for TransactionPriorities operator[]');
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
}
2024-10-28 15:16:23 +00:00
}
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
2024-10-28 15:16:23 +00:00
@override
String labelWithRate(TransactionPriority priorityType, [int? rate]) {
late int rateValue;
2024-11-06 15:06:52 +00:00
if (priorityType == BitcoinTransactionPriority.custom) {
2024-10-28 15:16:23 +00:00
if (rate == null) {
throw Exception('Rate must be provided for custom transaction priority');
}
rateValue = rate;
} else {
rateValue = this[priorityType];
}
return '${priorityType.toString()} (${rateValue} ${priorityType.units}/byte)';
}
2024-11-06 15:06:52 +00:00
@override
Map<String, int> toJson() {
return {
'unimportant': unimportant,
'normal': normal,
'elevated': elevated,
'priority': priority,
'custom': custom,
};
}
static BitcoinTransactionPriorities fromJson(Map<String, dynamic> json) {
return BitcoinTransactionPriorities(
unimportant: json['unimportant'] as int,
normal: json['normal'] as int,
elevated: json['elevated'] as int,
priority: json['priority'] as int,
custom: json['custom'] as int,
);
}
}
CW-432-Add-Bitcoin-Cash-BCH (#1041) * initial commit * creating and restoring a wallet * [skip ci] add transaction priority * fix send and unspent screen * fix transaction priority type * replace Unspend with BitcoinUnspent * add transaction creation * fix transaction details screen * minor fix * fix create side wallet * basic transaction creation flow * fix fiat amount calculation * edit wallet * minor fix * fix address book parsing * merge commit fixes * minor fixes * Update gradle.properties * fix bch unspent coins * minor fix * fix BitcoinCashTransactionPriority * Fetch tags first before switching to one of them * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * Update build_haven.sh * update transaction build function * Update build_haven.sh * add ability to rename and delete * fix address format * Update pubspec.lock * Revert "fix address format" This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f. * fix address format for exange * restore from qr * Update configure.dart * [skip ci] minor fix * fix default fee rate * Update onramper_buy_provider.dart * Update wallet_address_list_view_model.dart * PR comments fixes * Update exchange_view_model.dart * fix merge conflict * Update address_validator.dart * merge fixes * update initialMigrationVersion * move cw_bitbox to Cake tech * PR fixes * PR fixes * Fix configure.dart brackets * update the new version text after macos * dummy change to run workflow * Fix Nano restore from QR issue Fix Conflicts with main * PR fixes * Update app_config.sh --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2023-10-12 22:50:16 +00:00
2024-11-06 15:06:52 +00:00
class ElectrumTransactionPriorities implements TransactionPriorities {
const ElectrumTransactionPriorities({
2024-10-28 15:16:23 +00:00
required this.slow,
required this.medium,
required this.fast,
2024-11-06 15:06:52 +00:00
required this.custom,
2024-10-28 15:16:23 +00:00
});
final int slow;
final int medium;
final int fast;
2024-11-06 15:06:52 +00:00
final int custom;
2024-10-28 15:16:23 +00:00
@override
int operator [](TransactionPriority type) {
switch (type) {
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.slow:
2024-10-28 15:16:23 +00:00
return slow;
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.medium:
2024-10-28 15:16:23 +00:00
return medium;
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.fast:
2024-10-28 15:16:23 +00:00
return fast;
2024-11-06 15:06:52 +00:00
case ElectrumTransactionPriority.custom:
return custom;
2024-10-28 15:16:23 +00:00
default:
throw Exception('Unexpected token: $type for TransactionPriorities operator[]');
}
}
@override
String labelWithRate(TransactionPriority priorityType, [int? rate]) {
return '${priorityType.toString()} (${this[priorityType]} ${priorityType.units}/byte)';
}
2024-11-06 15:06:52 +00:00
factory ElectrumTransactionPriorities.fromList(List<int> list) {
2024-10-28 15:16:23 +00:00
if (list.length != 3) {
throw Exception(
'Unexpected list length: ${list.length} for BitcoinElectrumTransactionPriorities.fromList');
}
2024-11-06 15:06:52 +00:00
return ElectrumTransactionPriorities(
2024-10-28 15:16:23 +00:00
slow: list[0],
medium: list[1],
fast: list[2],
2024-11-06 15:06:52 +00:00
custom: 0,
);
}
@override
Map<String, int> toJson() {
return {
'slow': slow,
'medium': medium,
'fast': fast,
'custom': custom,
};
}
static ElectrumTransactionPriorities fromJson(Map<String, dynamic> json) {
return ElectrumTransactionPriorities(
slow: json['slow'] as int,
medium: json['medium'] as int,
fast: json['fast'] as int,
custom: json['custom'] as int,
2024-10-28 15:16:23 +00:00
);
}
}
2024-11-06 15:06:52 +00:00
TransactionPriorities deserializeTransactionPriorities(Map<String, dynamic> json) {
if (json.containsKey('unimportant')) {
return BitcoinTransactionPriorities.fromJson(json);
} else if (json.containsKey('slow')) {
return ElectrumTransactionPriorities.fromJson(json);
} else {
throw Exception('Unexpected token: $json for deserializeTransactionPriorities');
}
}