mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 11:16:36 +00:00
bch clean up linter warnings and unused variables
This commit is contained in:
parent
4dd8ae23c5
commit
039a9a68f6
1 changed files with 119 additions and 90 deletions
|
@ -6,7 +6,7 @@ import 'dart:typed_data';
|
||||||
import 'package:bech32/bech32.dart';
|
import 'package:bech32/bech32.dart';
|
||||||
import 'package:bip32/bip32.dart' as bip32;
|
import 'package:bip32/bip32.dart' as bip32;
|
||||||
import 'package:bip39/bip39.dart' as bip39;
|
import 'package:bip39/bip39.dart' as bip39;
|
||||||
import 'package:bitbox/bitbox.dart' as Bitbox;
|
import 'package:bitbox/bitbox.dart' as bitbox;
|
||||||
import 'package:bitcoindart/bitcoindart.dart';
|
import 'package:bitcoindart/bitcoindart.dart';
|
||||||
import 'package:bs58check/bs58check.dart' as bs58check;
|
import 'package:bs58check/bs58check.dart' as bs58check;
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
|
@ -258,7 +258,7 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateStoredChainHeight({required int newHeight}) async {
|
Future<void> updateStoredChainHeight({required int newHeight}) async {
|
||||||
DB.instance.put<dynamic>(
|
await DB.instance.put<dynamic>(
|
||||||
boxName: walletId, key: "storedChainHeight", value: newHeight);
|
boxName: walletId, key: "storedChainHeight", value: newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,8 +266,8 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
Uint8List? decodeBase58;
|
Uint8List? decodeBase58;
|
||||||
Segwit? decodeBech32;
|
Segwit? decodeBech32;
|
||||||
try {
|
try {
|
||||||
if (Bitbox.Address.detectFormat(address) == 0) {
|
if (bitbox.Address.detectFormat(address) == 0) {
|
||||||
address = Bitbox.Address.toLegacyAddress(address);
|
address = bitbox.Address.toLegacyAddress(address);
|
||||||
}
|
}
|
||||||
} catch (e, s) {}
|
} catch (e, s) {}
|
||||||
try {
|
try {
|
||||||
|
@ -609,7 +609,9 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
// get address tx counts
|
// get address tx counts
|
||||||
final counts = await _getBatchTxCount(addresses: txCountCallArgs);
|
final counts = await _getBatchTxCount(addresses: txCountCallArgs);
|
||||||
print("Counts $counts");
|
if (kDebugMode) {
|
||||||
|
print("Counts $counts");
|
||||||
|
}
|
||||||
// check and add appropriate addresses
|
// check and add appropriate addresses
|
||||||
for (int k = 0; k < txCountBatchSize; k++) {
|
for (int k = 0; k < txCountBatchSize; k++) {
|
||||||
int count = counts["${_id}_$k"]!;
|
int count = counts["${_id}_$k"]!;
|
||||||
|
@ -745,31 +747,35 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
// notify on new incoming transaction
|
// notify on new incoming transaction
|
||||||
for (final tx in unconfirmedTxnsToNotifyPending) {
|
for (final tx in unconfirmedTxnsToNotifyPending) {
|
||||||
if (tx.txType == "Received") {
|
if (tx.txType == "Received") {
|
||||||
NotificationApi.showNotification(
|
unawaited(
|
||||||
title: "Incoming transaction",
|
NotificationApi.showNotification(
|
||||||
body: walletName,
|
title: "Incoming transaction",
|
||||||
walletId: walletId,
|
body: walletName,
|
||||||
iconAssetName: Assets.svg.iconFor(coin: coin),
|
walletId: walletId,
|
||||||
date: DateTime.now(),
|
iconAssetName: Assets.svg.iconFor(coin: coin),
|
||||||
shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS,
|
date: DateTime.now(),
|
||||||
coinName: coin.name,
|
shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS,
|
||||||
txid: tx.txid,
|
coinName: coin.name,
|
||||||
confirmations: tx.confirmations,
|
txid: tx.txid,
|
||||||
requiredConfirmations: MINIMUM_CONFIRMATIONS,
|
confirmations: tx.confirmations,
|
||||||
|
requiredConfirmations: MINIMUM_CONFIRMATIONS,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
await txTracker.addNotifiedPending(tx.txid);
|
await txTracker.addNotifiedPending(tx.txid);
|
||||||
} else if (tx.txType == "Sent") {
|
} else if (tx.txType == "Sent") {
|
||||||
NotificationApi.showNotification(
|
unawaited(
|
||||||
title: "Sending transaction",
|
NotificationApi.showNotification(
|
||||||
body: walletName,
|
title: "Sending transaction",
|
||||||
walletId: walletId,
|
body: walletName,
|
||||||
iconAssetName: Assets.svg.iconFor(coin: coin),
|
walletId: walletId,
|
||||||
date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000),
|
iconAssetName: Assets.svg.iconFor(coin: coin),
|
||||||
shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS,
|
date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000),
|
||||||
coinName: coin.name,
|
shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS,
|
||||||
txid: tx.txid,
|
coinName: coin.name,
|
||||||
confirmations: tx.confirmations,
|
txid: tx.txid,
|
||||||
requiredConfirmations: MINIMUM_CONFIRMATIONS,
|
confirmations: tx.confirmations,
|
||||||
|
requiredConfirmations: MINIMUM_CONFIRMATIONS,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
await txTracker.addNotifiedPending(tx.txid);
|
await txTracker.addNotifiedPending(tx.txid);
|
||||||
}
|
}
|
||||||
|
@ -778,26 +784,30 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
// notify on confirmed
|
// notify on confirmed
|
||||||
for (final tx in unconfirmedTxnsToNotifyConfirmed) {
|
for (final tx in unconfirmedTxnsToNotifyConfirmed) {
|
||||||
if (tx.txType == "Received") {
|
if (tx.txType == "Received") {
|
||||||
NotificationApi.showNotification(
|
unawaited(
|
||||||
title: "Incoming transaction confirmed",
|
NotificationApi.showNotification(
|
||||||
body: walletName,
|
title: "Incoming transaction confirmed",
|
||||||
walletId: walletId,
|
body: walletName,
|
||||||
iconAssetName: Assets.svg.iconFor(coin: coin),
|
walletId: walletId,
|
||||||
date: DateTime.now(),
|
iconAssetName: Assets.svg.iconFor(coin: coin),
|
||||||
shouldWatchForUpdates: false,
|
date: DateTime.now(),
|
||||||
coinName: coin.name,
|
shouldWatchForUpdates: false,
|
||||||
|
coinName: coin.name,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await txTracker.addNotifiedConfirmed(tx.txid);
|
await txTracker.addNotifiedConfirmed(tx.txid);
|
||||||
} else if (tx.txType == "Sent") {
|
} else if (tx.txType == "Sent") {
|
||||||
NotificationApi.showNotification(
|
unawaited(
|
||||||
title: "Outgoing transaction confirmed",
|
NotificationApi.showNotification(
|
||||||
body: walletName,
|
title: "Outgoing transaction confirmed",
|
||||||
walletId: walletId,
|
body: walletName,
|
||||||
iconAssetName: Assets.svg.iconFor(coin: coin),
|
walletId: walletId,
|
||||||
date: DateTime.now(),
|
iconAssetName: Assets.svg.iconFor(coin: coin),
|
||||||
shouldWatchForUpdates: false,
|
date: DateTime.now(),
|
||||||
coinName: coin.name,
|
shouldWatchForUpdates: false,
|
||||||
|
coinName: coin.name,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
await txTracker.addNotifiedConfirmed(tx.txid);
|
await txTracker.addNotifiedConfirmed(tx.txid);
|
||||||
}
|
}
|
||||||
|
@ -862,7 +872,7 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
if (currentHeight != storedHeight) {
|
if (currentHeight != storedHeight) {
|
||||||
if (currentHeight != -1) {
|
if (currentHeight != -1) {
|
||||||
// -1 failed to fetch current height
|
// -1 failed to fetch current height
|
||||||
updateStoredChainHeight(newHeight: currentHeight);
|
await updateStoredChainHeight(newHeight: currentHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId));
|
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId));
|
||||||
|
@ -1147,10 +1157,12 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
bool validateAddress(String address) {
|
bool validateAddress(String address) {
|
||||||
try {
|
try {
|
||||||
// 0 for bitcoincash: address scheme, 1 for legacy address
|
// 0 for bitcoincash: address scheme, 1 for legacy address
|
||||||
final format = Bitbox.Address.detectFormat(address);
|
final format = bitbox.Address.detectFormat(address);
|
||||||
print("format $format");
|
if (kDebugMode) {
|
||||||
|
print("format $format");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (e, s) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1226,7 +1238,7 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shouldRefresh) {
|
if (shouldRefresh) {
|
||||||
refresh();
|
unawaited(refresh());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,12 +1534,14 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Array key is ${jsonEncode(arrayKey)}");
|
if (kDebugMode) {
|
||||||
|
print("Array key is ${jsonEncode(arrayKey)}");
|
||||||
|
}
|
||||||
final internalChainArray =
|
final internalChainArray =
|
||||||
DB.instance.get<dynamic>(boxName: walletId, key: arrayKey);
|
DB.instance.get<dynamic>(boxName: walletId, key: arrayKey);
|
||||||
if (derivePathType == DerivePathType.bip44) {
|
if (derivePathType == DerivePathType.bip44) {
|
||||||
if (Bitbox.Address.detectFormat(internalChainArray.last as String) == 1) {
|
if (bitbox.Address.detectFormat(internalChainArray.last as String) == 1) {
|
||||||
return Bitbox.Address.toCashAddress(internalChainArray.last as String);
|
return bitbox.Address.toCashAddress(internalChainArray.last as String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return internalChainArray.last as String;
|
return internalChainArray.last as String;
|
||||||
|
@ -1642,7 +1656,9 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
batches[batchNumber] = {};
|
batches[batchNumber] = {};
|
||||||
}
|
}
|
||||||
final scripthash = _convertToScriptHash(allAddresses[i], _network);
|
final scripthash = _convertToScriptHash(allAddresses[i], _network);
|
||||||
print("SCRIPT_HASH_FOR_ADDRESS ${allAddresses[i]} IS $scripthash");
|
if (kDebugMode) {
|
||||||
|
print("SCRIPT_HASH_FOR_ADDRESS ${allAddresses[i]} IS $scripthash");
|
||||||
|
}
|
||||||
batches[batchNumber]!.addAll({
|
batches[batchNumber]!.addAll({
|
||||||
scripthash: [scripthash]
|
scripthash: [scripthash]
|
||||||
});
|
});
|
||||||
|
@ -1818,20 +1834,28 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final Map<String, List<dynamic>> args = {};
|
final Map<String, List<dynamic>> args = {};
|
||||||
print("Address $addresses");
|
if (kDebugMode) {
|
||||||
|
print("Address $addresses");
|
||||||
|
}
|
||||||
for (final entry in addresses.entries) {
|
for (final entry in addresses.entries) {
|
||||||
args[entry.key] = [_convertToScriptHash(entry.value, _network)];
|
args[entry.key] = [_convertToScriptHash(entry.value, _network)];
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Args ${jsonEncode(args)}");
|
if (kDebugMode) {
|
||||||
|
print("Args ${jsonEncode(args)}");
|
||||||
|
}
|
||||||
|
|
||||||
final response = await electrumXClient.getBatchHistory(args: args);
|
final response = await electrumXClient.getBatchHistory(args: args);
|
||||||
print("Response ${jsonEncode(response)}");
|
if (kDebugMode) {
|
||||||
|
print("Response ${jsonEncode(response)}");
|
||||||
|
}
|
||||||
final Map<String, int> result = {};
|
final Map<String, int> result = {};
|
||||||
for (final entry in response.entries) {
|
for (final entry in response.entries) {
|
||||||
result[entry.key] = entry.value.length;
|
result[entry.key] = entry.value.length;
|
||||||
}
|
}
|
||||||
print("result ${jsonEncode(result)}");
|
if (kDebugMode) {
|
||||||
|
print("result ${jsonEncode(result)}");
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
|
@ -1995,8 +2019,8 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
/// Returns the scripthash or throws an exception on invalid bch address
|
/// Returns the scripthash or throws an exception on invalid bch address
|
||||||
String _convertToScriptHash(String bchAddress, NetworkType network) {
|
String _convertToScriptHash(String bchAddress, NetworkType network) {
|
||||||
try {
|
try {
|
||||||
if (Bitbox.Address.detectFormat(bchAddress) == 0) {
|
if (bitbox.Address.detectFormat(bchAddress) == 0) {
|
||||||
bchAddress = Bitbox.Address.toLegacyAddress(bchAddress);
|
bchAddress = bitbox.Address.toLegacyAddress(bchAddress);
|
||||||
}
|
}
|
||||||
final output = Address.addressToOutputScript(bchAddress, network);
|
final output = Address.addressToOutputScript(bchAddress, network);
|
||||||
final hash = sha256.convert(output.toList(growable: false)).toString();
|
final hash = sha256.convert(output.toList(growable: false)).toString();
|
||||||
|
@ -2073,8 +2097,8 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
List<String> allAddressesOld = await _fetchAllOwnAddresses();
|
List<String> allAddressesOld = await _fetchAllOwnAddresses();
|
||||||
List<String> allAddresses = [];
|
List<String> allAddresses = [];
|
||||||
for (String address in allAddressesOld) {
|
for (String address in allAddressesOld) {
|
||||||
if (Bitbox.Address.detectFormat(address) == 1) {
|
if (bitbox.Address.detectFormat(address) == 1) {
|
||||||
allAddresses.add(Bitbox.Address.toCashAddress(address));
|
allAddresses.add(bitbox.Address.toCashAddress(address));
|
||||||
} else {
|
} else {
|
||||||
allAddresses.add(address);
|
allAddresses.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2085,8 +2109,8 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
as List<dynamic>;
|
as List<dynamic>;
|
||||||
List<dynamic> changeAddressesP2PKH = [];
|
List<dynamic> changeAddressesP2PKH = [];
|
||||||
for (var address in changeAddressesP2PKHOld) {
|
for (var address in changeAddressesP2PKHOld) {
|
||||||
if (Bitbox.Address.detectFormat(address as String) == 1) {
|
if (bitbox.Address.detectFormat(address as String) == 1) {
|
||||||
changeAddressesP2PKH.add(Bitbox.Address.toCashAddress(address));
|
changeAddressesP2PKH.add(bitbox.Address.toCashAddress(address));
|
||||||
} else {
|
} else {
|
||||||
changeAddressesP2PKH.add(address);
|
changeAddressesP2PKH.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2108,21 +2132,26 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
unconfirmedCachedTransactions
|
unconfirmedCachedTransactions
|
||||||
.removeWhere((key, value) => value.confirmedStatus);
|
.removeWhere((key, value) => value.confirmedStatus);
|
||||||
|
|
||||||
print("CACHED_TRANSACTIONS_IS $cachedTransactions");
|
if (kDebugMode) {
|
||||||
|
print("CACHED_TRANSACTIONS_IS $cachedTransactions");
|
||||||
|
}
|
||||||
if (cachedTransactions != null) {
|
if (cachedTransactions != null) {
|
||||||
for (final tx in allTxHashes.toList(growable: false)) {
|
for (final tx in allTxHashes.toList(growable: false)) {
|
||||||
final txHeight = tx["height"] as int;
|
final txHeight = tx["height"] as int;
|
||||||
if (txHeight > 0 &&
|
if (txHeight > 0 &&
|
||||||
txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) {
|
txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) {
|
||||||
if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) {
|
if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) {
|
||||||
print(cachedTransactions.findTransaction(tx["tx_hash"] as String));
|
if (kDebugMode) {
|
||||||
print(unconfirmedCachedTransactions[tx["tx_hash"] as String]);
|
print(
|
||||||
|
cachedTransactions.findTransaction(tx["tx_hash"] as String));
|
||||||
|
print(unconfirmedCachedTransactions[tx["tx_hash"] as String]);
|
||||||
|
}
|
||||||
final cachedTx =
|
final cachedTx =
|
||||||
cachedTransactions.findTransaction(tx["tx_hash"] as String);
|
cachedTransactions.findTransaction(tx["tx_hash"] as String);
|
||||||
if (!(cachedTx != null &&
|
if (!(cachedTx != null &&
|
||||||
addressType(address: cachedTx.address) ==
|
addressType(address: cachedTx.address) ==
|
||||||
DerivePathType.bip44 &&
|
DerivePathType.bip44 &&
|
||||||
Bitbox.Address.detectFormat(cachedTx.address) == 1)) {
|
bitbox.Address.detectFormat(cachedTx.address) == 1)) {
|
||||||
allTxHashes.remove(tx);
|
allTxHashes.remove(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2782,8 +2811,8 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
final n = output["n"];
|
final n = output["n"];
|
||||||
if (n != null && n == utxosToUse[i].vout) {
|
if (n != null && n == utxosToUse[i].vout) {
|
||||||
String address = output["scriptPubKey"]["addresses"][0] as String;
|
String address = output["scriptPubKey"]["addresses"][0] as String;
|
||||||
if (Bitbox.Address.detectFormat(address) == 0) {
|
if (bitbox.Address.detectFormat(address) == 0) {
|
||||||
address = Bitbox.Address.toLegacyAddress(address);
|
address = bitbox.Address.toLegacyAddress(address);
|
||||||
}
|
}
|
||||||
if (!addressTxid.containsKey(address)) {
|
if (!addressTxid.containsKey(address)) {
|
||||||
addressTxid[address] = <String>[];
|
addressTxid[address] = <String>[];
|
||||||
|
@ -2814,8 +2843,8 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
);
|
);
|
||||||
for (int i = 0; i < p2pkhLength; i++) {
|
for (int i = 0; i < p2pkhLength; i++) {
|
||||||
String address = addressesP2PKH[i];
|
String address = addressesP2PKH[i];
|
||||||
if (Bitbox.Address.detectFormat(address) == 0) {
|
if (bitbox.Address.detectFormat(address) == 0) {
|
||||||
address = Bitbox.Address.toLegacyAddress(address);
|
address = bitbox.Address.toLegacyAddress(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
// receives
|
// receives
|
||||||
|
@ -2950,36 +2979,36 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
required List<String> recipients,
|
required List<String> recipients,
|
||||||
required List<int> satoshiAmounts,
|
required List<int> satoshiAmounts,
|
||||||
}) async {
|
}) async {
|
||||||
final builder = Bitbox.Bitbox.transactionBuilder();
|
final builder = bitbox.Bitbox.transactionBuilder();
|
||||||
|
|
||||||
// retrieve address' utxos from the rest api
|
// retrieve address' utxos from the rest api
|
||||||
List<Bitbox.Utxo> _utxos =
|
List<bitbox.Utxo> _utxos =
|
||||||
[]; // await Bitbox.Address.utxo(address) as List<Bitbox.Utxo>;
|
[]; // await Bitbox.Address.utxo(address) as List<Bitbox.Utxo>;
|
||||||
utxosToUse.forEach((element) {
|
for (var element in utxosToUse) {
|
||||||
_utxos.add(Bitbox.Utxo(
|
_utxos.add(bitbox.Utxo(
|
||||||
element.txid,
|
element.txid,
|
||||||
element.vout,
|
element.vout,
|
||||||
Bitbox.BitcoinCash.fromSatoshi(element.value),
|
bitbox.BitcoinCash.fromSatoshi(element.value),
|
||||||
element.value,
|
element.value,
|
||||||
0,
|
0,
|
||||||
MINIMUM_CONFIRMATIONS + 1));
|
MINIMUM_CONFIRMATIONS + 1));
|
||||||
});
|
}
|
||||||
Logger.print("bch utxos: ${_utxos}");
|
Logger.print("bch utxos: $_utxos");
|
||||||
|
|
||||||
// placeholder for input signatures
|
// placeholder for input signatures
|
||||||
final signatures = <Map>[];
|
final List<Map<dynamic, dynamic>> signatures = [];
|
||||||
|
|
||||||
// placeholder for total input balance
|
// placeholder for total input balance
|
||||||
int totalBalance = 0;
|
// int totalBalance = 0;
|
||||||
|
|
||||||
// iterate through the list of address _utxos and use them as inputs for the
|
// iterate through the list of address _utxos and use them as inputs for the
|
||||||
// withdrawal transaction
|
// withdrawal transaction
|
||||||
_utxos.forEach((Bitbox.Utxo utxo) {
|
for (var utxo in _utxos) {
|
||||||
// add the utxo as an input for the transaction
|
// add the utxo as an input for the transaction
|
||||||
builder.addInput(utxo.txid, utxo.vout);
|
builder.addInput(utxo.txid, utxo.vout);
|
||||||
final ec = utxoSigningData[utxo.txid]["keyPair"] as ECPair;
|
final ec = utxoSigningData[utxo.txid]["keyPair"] as ECPair;
|
||||||
|
|
||||||
final bitboxEC = Bitbox.ECPair.fromWIF(ec.toWIF());
|
final bitboxEC = bitbox.ECPair.fromWIF(ec.toWIF());
|
||||||
|
|
||||||
// add a signature to the list to be used later
|
// add a signature to the list to be used later
|
||||||
signatures.add({
|
signatures.add({
|
||||||
|
@ -2988,15 +3017,15 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
"original_amount": utxo.satoshis
|
"original_amount": utxo.satoshis
|
||||||
});
|
});
|
||||||
|
|
||||||
totalBalance += utxo.satoshis;
|
// totalBalance += utxo.satoshis;
|
||||||
});
|
}
|
||||||
|
|
||||||
// calculate the fee based on number of inputs and one expected output
|
// calculate the fee based on number of inputs and one expected output
|
||||||
final fee =
|
// final fee =
|
||||||
Bitbox.BitcoinCash.getByteCount(signatures.length, recipients.length);
|
// bitbox.BitcoinCash.getByteCount(signatures.length, recipients.length);
|
||||||
|
|
||||||
// calculate how much balance will be left over to spend after the fee
|
// calculate how much balance will be left over to spend after the fee
|
||||||
final sendAmount = totalBalance - fee;
|
// final sendAmount = totalBalance - fee;
|
||||||
|
|
||||||
// add the output based on the address provided in the testing data
|
// add the output based on the address provided in the testing data
|
||||||
for (int i = 0; i < recipients.length; i++) {
|
for (int i = 0; i < recipients.length; i++) {
|
||||||
|
@ -3006,12 +3035,12 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sign all inputs
|
// sign all inputs
|
||||||
signatures.forEach((signature) {
|
for (var signature in signatures) {
|
||||||
builder.sign(
|
builder.sign(
|
||||||
signature["vin"] as int,
|
signature["vin"] as int,
|
||||||
signature["key_pair"] as Bitbox.ECPair,
|
signature["key_pair"] as bitbox.ECPair,
|
||||||
signature["original_amount"] as int);
|
signature["original_amount"] as int);
|
||||||
});
|
}
|
||||||
|
|
||||||
// build the transaction
|
// build the transaction
|
||||||
final tx = builder.build();
|
final tx = builder.build();
|
||||||
|
@ -3038,7 +3067,7 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
);
|
);
|
||||||
|
|
||||||
// clear cache
|
// clear cache
|
||||||
_cachedElectrumXClient.clearSharedTransactionCache(coin: coin);
|
await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin);
|
||||||
|
|
||||||
// back up data
|
// back up data
|
||||||
await _rescanBackup();
|
await _rescanBackup();
|
||||||
|
|
Loading…
Reference in a new issue