mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
WIP: very basic CPFP
This commit is contained in:
parent
e2c81a1af0
commit
318932022e
3 changed files with 24 additions and 2 deletions
|
@ -6,6 +6,7 @@ import '../../crypto_currency/crypto_currency.dart';
|
|||
import '../../crypto_currency/interfaces/paynym_currency_interface.dart';
|
||||
import '../intermediate/bip39_hd_wallet.dart';
|
||||
import '../wallet_mixin_interfaces/coin_control_interface.dart';
|
||||
import '../wallet_mixin_interfaces/cpfp_interface.dart';
|
||||
import '../wallet_mixin_interfaces/electrumx_interface.dart';
|
||||
import '../wallet_mixin_interfaces/paynym_interface.dart';
|
||||
import '../wallet_mixin_interfaces/rbf_interface.dart';
|
||||
|
@ -15,7 +16,8 @@ class BitcoinWallet<T extends PaynymCurrencyInterface> extends Bip39HDWallet<T>
|
|||
ElectrumXInterface<T>,
|
||||
CoinControlInterface,
|
||||
PaynymInterface<T>,
|
||||
RbfInterface<T> {
|
||||
RbfInterface<T>,
|
||||
CpfpInterface<T> {
|
||||
@override
|
||||
int get isarTransactionVersion => 2;
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import '../../crypto_currency/interfaces/electrumx_currency_interface.dart';
|
||||
import 'electrumx_interface.dart';
|
||||
|
||||
mixin CpfpInterface<T extends ElectrumXCurrencyInterface>
|
||||
on ElectrumXInterface<T> {
|
||||
//
|
||||
}
|
|
@ -26,6 +26,7 @@ import '../../models/tx_data.dart';
|
|||
import '../impl/bitcoin_wallet.dart';
|
||||
import '../impl/peercoin_wallet.dart';
|
||||
import '../intermediate/bip39_hd_wallet.dart';
|
||||
import 'cpfp_interface.dart';
|
||||
import 'paynym_interface.dart';
|
||||
|
||||
mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
|
||||
|
@ -122,12 +123,16 @@ mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
|
|||
utxos ?? await mainDB.getUTXOs(walletId).findAll();
|
||||
final currentChainHeight = await chainHeight;
|
||||
|
||||
final canCPFP = this is CpfpInterface && coinControl;
|
||||
|
||||
final spendableOutputs = availableOutputs
|
||||
.where(
|
||||
(e) =>
|
||||
!e.isBlocked &&
|
||||
(e.used != true) &&
|
||||
e.isConfirmed(currentChainHeight, cryptoCurrency.minConfirms),
|
||||
(canCPFP ||
|
||||
e.isConfirmed(
|
||||
currentChainHeight, cryptoCurrency.minConfirms)),
|
||||
)
|
||||
.toList();
|
||||
final spendableSatoshiValue =
|
||||
|
@ -1655,6 +1660,14 @@ mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
|
|||
|
||||
final bool coinControl = utxos != null;
|
||||
|
||||
if (coinControl &&
|
||||
this is CpfpInterface &&
|
||||
txData.amount ==
|
||||
(info.cachedBalance.spendable +
|
||||
info.cachedBalance.pendingSpendable)) {
|
||||
isSendAll = true;
|
||||
}
|
||||
|
||||
final result = await coinSelection(
|
||||
txData: txData.copyWith(feeRateAmount: -1),
|
||||
isSendAll: isSendAll,
|
||||
|
|
Loading…
Reference in a new issue