mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
replace Unspend with BitcoinUnspent
This commit is contained in:
parent
5f59bd939e
commit
c563e300f8
4 changed files with 65 additions and 82 deletions
|
@ -1,5 +1,6 @@
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
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_balance.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet.dart';
|
import 'package:cw_bitcoin/electrum_wallet.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet_snapshot.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,
|
Future<PendingBitcoinTransaction> createTransaction(Object credentials,
|
||||||
[List<Object>? unspents, Object? wallet]) async {
|
[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 builder = bitbox.Bitbox.transactionBuilder(testnet: false);
|
||||||
// final utxosToUse = unspents as List<UnspentCash>;
|
// final utxosToUse = unspents as List<UnspentCash>;
|
||||||
// final _wallet = wallet as BitcoinCashWallet;
|
// final _wallet = wallet as BitcoinCashWallet;
|
||||||
|
|
|
@ -130,11 +130,11 @@ class CWBitcoin extends Bitcoin {
|
||||||
=> (priority as BitcoinTransactionPriority).labelWithRate(rate);
|
=> (priority as BitcoinTransactionPriority).labelWithRate(rate);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Unspent> getUnspents(Object wallet) {
|
List<BitcoinUnspent> getUnspents(Object wallet) {
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
final bitcoinWallet = wallet as ElectrumWallet;
|
||||||
return bitcoinWallet.unspentCoins
|
return bitcoinWallet.unspentCoins
|
||||||
.map((BitcoinUnspent bitcoinUnspent) => Unspent(
|
.map((BitcoinUnspent bitcoinUnspent) => BitcoinUnspent(
|
||||||
bitcoinUnspent.address.address,
|
bitcoinUnspent.address,
|
||||||
bitcoinUnspent.hash,
|
bitcoinUnspent.hash,
|
||||||
bitcoinUnspent.value,
|
bitcoinUnspent.value,
|
||||||
bitcoinUnspent.vout))
|
bitcoinUnspent.vout))
|
||||||
|
|
|
@ -26,10 +26,10 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
||||||
final amount = bitcoin!.formatterBitcoinAmountToString(amount: elem.value) +
|
final amount = bitcoin!.formatterBitcoinAmountToString(amount: elem.value) +
|
||||||
' ${wallet.currency.title}';
|
' ${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(
|
return UnspentCoinsItem(
|
||||||
address: elem.address,
|
address: elem.address.address,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
hash: elem.hash,
|
hash: elem.hash,
|
||||||
isFrozen: info?.isFrozen ?? false,
|
isFrozen: info?.isFrozen ?? false,
|
||||||
|
|
|
@ -51,24 +51,6 @@ import 'package:cw_bitcoin/litecoin_wallet_service.dart';
|
||||||
""";
|
""";
|
||||||
const bitcoinCwPart = "part 'cw_bitcoin.dart';";
|
const bitcoinCwPart = "part 'cw_bitcoin.dart';";
|
||||||
const bitcoinContent = """
|
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 {
|
abstract class Bitcoin {
|
||||||
TransactionPriority getMediumTransactionPriority();
|
TransactionPriority getMediumTransactionPriority();
|
||||||
|
|
||||||
|
@ -96,7 +78,7 @@ abstract class Bitcoin {
|
||||||
int formatterStringDoubleToBitcoinAmount(String amount);
|
int formatterStringDoubleToBitcoinAmount(String amount);
|
||||||
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate);
|
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate);
|
||||||
|
|
||||||
List<Unspent> getUnspents(Object wallet);
|
List<BitcoinUnspent> getUnspents(Object wallet);
|
||||||
void updateUnspents(Object wallet);
|
void updateUnspents(Object wallet);
|
||||||
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
|
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
|
||||||
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
|
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
|
||||||
|
|
Loading…
Reference in a new issue