replace Unspend with BitcoinUnspent

This commit is contained in:
Serhii 2023-08-18 12:32:59 +03:00
parent 5f59bd939e
commit c563e300f8
4 changed files with 65 additions and 82 deletions

View file

@ -1,5 +1,6 @@
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
import 'package:cw_bitcoin/bitcoin_address_record.dart';
import 'package:cw_bitcoin/bitcoin_unspent.dart';
import 'package:cw_bitcoin/electrum_balance.dart';
import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_bitcoin/electrum_wallet_snapshot.dart';
@ -93,7 +94,7 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
Future<PendingBitcoinTransaction> createTransaction(Object credentials,
[List<Object>? unspents, Object? wallet]) async {
// final utxoSigningData = await fetchBuildTxData(unspents as List<UnspentCash>, wallet as BitcoinCashWalletBase);
// final utxoSigningData = await fetchBuildTxData(unspents as List<BitcoinUnspent>, wallet as BitcoinCashWalletBase);
// final builder = bitbox.Bitbox.transactionBuilder(testnet: false);
// final utxosToUse = unspents as List<UnspentCash>;
// final _wallet = wallet as BitcoinCashWallet;

View file

@ -130,11 +130,11 @@ class CWBitcoin extends Bitcoin {
=> (priority as BitcoinTransactionPriority).labelWithRate(rate);
@override
List<Unspent> getUnspents(Object wallet) {
List<BitcoinUnspent> getUnspents(Object wallet) {
final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.unspentCoins
.map((BitcoinUnspent bitcoinUnspent) => Unspent(
bitcoinUnspent.address.address,
.map((BitcoinUnspent bitcoinUnspent) => BitcoinUnspent(
bitcoinUnspent.address,
bitcoinUnspent.hash,
bitcoinUnspent.value,
bitcoinUnspent.vout))

View file

@ -26,10 +26,10 @@ abstract class UnspentCoinsListViewModelBase with Store {
final amount = bitcoin!.formatterBitcoinAmountToString(amount: elem.value) +
' ${wallet.currency.title}';
final info = getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout);
final info = getUnspentCoinInfo(elem.hash, elem.address.address, elem.value, elem.vout);
return UnspentCoinsItem(
address: elem.address,
address: elem.address.address,
amount: amount,
hash: elem.hash,
isFrozen: info?.isFrozen ?? false,

View file

@ -51,24 +51,6 @@ import 'package:cw_bitcoin/litecoin_wallet_service.dart';
""";
const bitcoinCwPart = "part 'cw_bitcoin.dart';";
const bitcoinContent = """
class Unspent {
Unspent(this.address, this.hash, this.value, this.vout)
: isSending = true,
isFrozen = false,
note = '';
final String address;
final String hash;
final int value;
final int vout;
bool isSending;
bool isFrozen;
String note;
bool get isP2wpkh => address.startsWith('bc') || address.startsWith('ltc');
}
abstract class Bitcoin {
TransactionPriority getMediumTransactionPriority();
@ -96,7 +78,7 @@ abstract class Bitcoin {
int formatterStringDoubleToBitcoinAmount(String amount);
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate);
List<Unspent> getUnspents(Object wallet);
List<BitcoinUnspent> getUnspents(Object wallet);
void updateUnspents(Object wallet);
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);