2023-11-06 21:37:18 +00:00
|
|
|
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
2023-09-14 23:34:01 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
|
2023-11-03 19:46:55 +00:00
|
|
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
2023-09-14 23:34:01 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
|
|
|
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
2023-11-03 19:46:55 +00:00
|
|
|
import 'package:web3dart/web3dart.dart' as web3dart;
|
2023-09-14 23:34:01 +00:00
|
|
|
|
|
|
|
class TxData {
|
|
|
|
final FeeRateType? feeRateType;
|
|
|
|
final int? feeRateAmount;
|
|
|
|
final int? satsPerVByte;
|
|
|
|
|
|
|
|
final Amount? fee;
|
|
|
|
final int? vSize;
|
|
|
|
|
|
|
|
final String? raw;
|
|
|
|
|
|
|
|
final String? txid;
|
|
|
|
final String? txHash;
|
|
|
|
|
|
|
|
final String? note;
|
|
|
|
final String? noteOnChain;
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
final String? memo;
|
|
|
|
|
2023-09-14 23:34:01 +00:00
|
|
|
final List<({String address, Amount amount})>? recipients;
|
|
|
|
final Set<UTXO>? utxos;
|
|
|
|
|
|
|
|
final String? changeAddress;
|
|
|
|
|
|
|
|
final String? frostMSConfig;
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
// paynym specific
|
|
|
|
final PaynymAccountLite? paynymAccountLite;
|
|
|
|
|
|
|
|
// eth token specific
|
|
|
|
final web3dart.Transaction? web3dartTransaction;
|
|
|
|
final int? nonce;
|
|
|
|
final BigInt? chainId;
|
|
|
|
final BigInt? feeInWei;
|
|
|
|
|
2023-11-06 21:37:18 +00:00
|
|
|
// wownero specific
|
|
|
|
final PendingWowneroTransaction? pendingWowneroTransaction;
|
|
|
|
|
2023-09-14 23:34:01 +00:00
|
|
|
TxData({
|
|
|
|
this.feeRateType,
|
|
|
|
this.feeRateAmount,
|
|
|
|
this.satsPerVByte,
|
|
|
|
this.fee,
|
|
|
|
this.vSize,
|
|
|
|
this.raw,
|
|
|
|
this.txid,
|
|
|
|
this.txHash,
|
|
|
|
this.note,
|
|
|
|
this.noteOnChain,
|
2023-11-03 19:46:55 +00:00
|
|
|
this.memo,
|
2023-09-14 23:34:01 +00:00
|
|
|
this.recipients,
|
|
|
|
this.utxos,
|
|
|
|
this.changeAddress,
|
|
|
|
this.frostMSConfig,
|
2023-11-03 19:46:55 +00:00
|
|
|
this.paynymAccountLite,
|
|
|
|
this.web3dartTransaction,
|
|
|
|
this.nonce,
|
|
|
|
this.chainId,
|
|
|
|
this.feeInWei,
|
2023-11-06 21:37:18 +00:00
|
|
|
this.pendingWowneroTransaction,
|
2023-09-14 23:34:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Amount? get amount => recipients != null && recipients!.isNotEmpty
|
|
|
|
? recipients!
|
|
|
|
.map((e) => e.amount)
|
|
|
|
.reduce((total, amount) => total += amount)
|
|
|
|
: null;
|
|
|
|
|
|
|
|
int? get estimatedSatsPerVByte => fee != null && vSize != null
|
|
|
|
? (fee!.raw ~/ BigInt.from(vSize!)).toInt()
|
|
|
|
: null;
|
|
|
|
|
|
|
|
TxData copyWith({
|
|
|
|
FeeRateType? feeRateType,
|
|
|
|
int? feeRateAmount,
|
|
|
|
int? satsPerVByte,
|
|
|
|
Amount? fee,
|
|
|
|
int? vSize,
|
|
|
|
String? raw,
|
|
|
|
String? txid,
|
|
|
|
String? txHash,
|
|
|
|
String? note,
|
|
|
|
String? noteOnChain,
|
2023-11-03 19:46:55 +00:00
|
|
|
String? memo,
|
2023-09-14 23:34:01 +00:00
|
|
|
Set<UTXO>? utxos,
|
|
|
|
List<({String address, Amount amount})>? recipients,
|
|
|
|
String? frostMSConfig,
|
|
|
|
String? changeAddress,
|
2023-11-03 19:46:55 +00:00
|
|
|
PaynymAccountLite? paynymAccountLite,
|
|
|
|
web3dart.Transaction? web3dartTransaction,
|
|
|
|
int? nonce,
|
|
|
|
BigInt? chainId,
|
|
|
|
BigInt? feeInWei,
|
2023-11-06 21:37:18 +00:00
|
|
|
PendingWowneroTransaction? pendingWowneroTransaction,
|
2023-09-14 23:34:01 +00:00
|
|
|
}) {
|
|
|
|
return TxData(
|
|
|
|
feeRateType: feeRateType ?? this.feeRateType,
|
|
|
|
feeRateAmount: feeRateAmount ?? this.feeRateAmount,
|
|
|
|
satsPerVByte: satsPerVByte ?? this.satsPerVByte,
|
|
|
|
fee: fee ?? this.fee,
|
|
|
|
vSize: vSize ?? this.vSize,
|
|
|
|
raw: raw ?? this.raw,
|
|
|
|
txid: txid ?? this.txid,
|
|
|
|
txHash: txHash ?? this.txHash,
|
|
|
|
note: note ?? this.note,
|
|
|
|
noteOnChain: noteOnChain ?? this.noteOnChain,
|
2023-11-03 19:46:55 +00:00
|
|
|
memo: memo ?? this.memo,
|
2023-09-14 23:34:01 +00:00
|
|
|
utxos: utxos ?? this.utxos,
|
|
|
|
recipients: recipients ?? this.recipients,
|
|
|
|
frostMSConfig: frostMSConfig ?? this.frostMSConfig,
|
|
|
|
changeAddress: changeAddress ?? this.changeAddress,
|
2023-11-03 19:46:55 +00:00
|
|
|
paynymAccountLite: paynymAccountLite ?? this.paynymAccountLite,
|
|
|
|
web3dartTransaction: web3dartTransaction ?? this.web3dartTransaction,
|
|
|
|
nonce: nonce ?? this.nonce,
|
|
|
|
chainId: chainId ?? this.chainId,
|
|
|
|
feeInWei: feeInWei ?? this.feeInWei,
|
2023-11-06 21:37:18 +00:00
|
|
|
pendingWowneroTransaction:
|
|
|
|
pendingWowneroTransaction ?? this.pendingWowneroTransaction,
|
2023-09-14 23:34:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => 'TxData{'
|
|
|
|
'feeRateType: $feeRateType, '
|
|
|
|
'feeRateAmount: $feeRateAmount, '
|
|
|
|
'satsPerVByte: $satsPerVByte, '
|
|
|
|
'fee: $fee, '
|
|
|
|
'vSize: $vSize, '
|
|
|
|
'raw: $raw, '
|
|
|
|
'txid: $txid, '
|
|
|
|
'txHash: $txHash, '
|
|
|
|
'note: $note, '
|
|
|
|
'noteOnChain: $noteOnChain, '
|
2023-11-03 19:46:55 +00:00
|
|
|
'memo: $memo, '
|
2023-09-14 23:34:01 +00:00
|
|
|
'recipients: $recipients, '
|
|
|
|
'utxos: $utxos, '
|
|
|
|
'frostMSConfig: $frostMSConfig, '
|
2023-11-03 19:46:55 +00:00
|
|
|
'changeAddress: $changeAddress, '
|
|
|
|
'paynymAccountLite: $paynymAccountLite, '
|
|
|
|
'web3dartTransaction: $web3dartTransaction, '
|
|
|
|
'nonce: $nonce, '
|
|
|
|
'chainId: $chainId, '
|
|
|
|
'feeInWei: $feeInWei, '
|
2023-11-06 21:37:18 +00:00
|
|
|
'pendingWowneroTransaction: $pendingWowneroTransaction, '
|
2023-09-14 23:34:01 +00:00
|
|
|
'}';
|
|
|
|
}
|