This commit is contained in:
julian 2024-05-10 11:45:23 -06:00
parent 5cda658bd2
commit a05287bae4

View file

@ -51,8 +51,9 @@ class PeercoinWallet extends Bip39HDWallet
Amount roughFeeEstimate(int inputCount, int outputCount, int feeRatePerKB) {
return Amount(
rawValue: BigInt.from(
((42 + (272 * inputCount) + (128 * outputCount)) / 4).ceil() *
(feeRatePerKB / 1000).ceil()),
((42 + (272 * inputCount) + (128 * outputCount)) / 4).ceil() *
(feeRatePerKB / 1000).ceil(),
),
fractionDigits: cryptoCurrency.fractionDigits,
);
}
@ -83,14 +84,15 @@ class PeercoinWallet extends Bip39HDWallet
@override
Future<void> updateTransactions() async {
// Get all addresses.
List<Address> allAddressesOld = await fetchAddressesForElectrumXScan();
final List<Address> allAddressesOld =
await fetchAddressesForElectrumXScan();
// Separate receiving and change addresses.
Set<String> receivingAddresses = allAddressesOld
final Set<String> receivingAddresses = allAddressesOld
.where((e) => e.subType == AddressSubType.receiving)
.map((e) => e.value)
.toSet();
Set<String> changeAddresses = allAddressesOld
final Set<String> changeAddresses = allAddressesOld
.where((e) => e.subType == AddressSubType.change)
.map((e) => e.value)
.toSet();
@ -103,7 +105,7 @@ class PeercoinWallet extends Bip39HDWallet
await fetchHistory(allAddressesSet);
// Only parse new txs (not in db yet).
List<Map<String, dynamic>> allTransactions = [];
final List<Map<String, dynamic>> allTransactions = [];
for (final txHash in allTxHashes) {
// Check for duplicates by searching for tx by tx_hash in db.
final storedTx = await mainDB.isar.transactionV2s
@ -164,8 +166,8 @@ class PeercoinWallet extends Bip39HDWallet
);
final prevOutJson = Map<String, dynamic>.from(
(inputTx["vout"] as List).firstWhere((e) => e["n"] == vout)
as Map);
(inputTx["vout"] as List).firstWhere((e) => e["n"] == vout) as Map,
);
final prevOut = OutputV2.fromElectrumXJson(
prevOutJson,
@ -239,7 +241,7 @@ class PeercoinWallet extends Bip39HDWallet
.fold(BigInt.zero, (value, element) => value + element);
TransactionType type;
TransactionSubType subType = TransactionSubType.none;
const TransactionSubType subType = TransactionSubType.none;
// At least one input was owned by this wallet.
if (wasSentFromThisWallet) {