mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
remove unused code
This commit is contained in:
parent
99a36f1587
commit
140f1468f9
1 changed files with 0 additions and 69 deletions
|
@ -4769,75 +4769,6 @@ class FiroWallet extends CoinServiceAPI
|
|||
this.isActive = isActive;
|
||||
};
|
||||
|
||||
Future<dynamic> getCoinsToJoinSplit(
|
||||
int required,
|
||||
) async {
|
||||
List<DartLelantusEntry> coins = await _getLelantusEntry();
|
||||
if (required > LELANTUS_VALUE_SPEND_LIMIT_PER_TRANSACTION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int availableBalance = coins.fold(
|
||||
0, (previousValue, element) => previousValue + element.amount);
|
||||
|
||||
if (required > availableBalance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// sort by biggest amount. if it is same amount we will prefer the older block
|
||||
coins.sort((a, b) =>
|
||||
(a.amount != b.amount ? a.amount > b.amount : a.height < b.height)
|
||||
? -1
|
||||
: 1);
|
||||
int spendVal = 0;
|
||||
|
||||
List<DartLelantusEntry> coinsToSpend = [];
|
||||
|
||||
while (spendVal < required) {
|
||||
if (coins.isEmpty) {
|
||||
break;
|
||||
}
|
||||
|
||||
DartLelantusEntry? chosen;
|
||||
int need = required - spendVal;
|
||||
|
||||
var itr = coins.first;
|
||||
if (need >= itr.amount) {
|
||||
chosen = itr;
|
||||
coins.remove(itr);
|
||||
} else {
|
||||
for (int index = coins.length - 1; index != 0; index--) {
|
||||
var coinIt = coins[index];
|
||||
var nextItr = coins[index - 1];
|
||||
|
||||
if (coinIt.amount >= need &&
|
||||
(index - 1 == 0 || nextItr.amount != coinIt.amount)) {
|
||||
chosen = coinIt;
|
||||
coins.remove(chosen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: investigate the bug here where chosen is null, conditions, given one mint
|
||||
spendVal += chosen!.amount;
|
||||
coinsToSpend.insert(coinsToSpend.length, chosen);
|
||||
}
|
||||
|
||||
// sort by group id ay ascending order. it is mandatory for creating proper joinsplit
|
||||
coinsToSpend.sort((a, b) => a.anonymitySetId < b.anonymitySetId ? 1 : -1);
|
||||
|
||||
int changeToMint = spendVal - required;
|
||||
List<int> indices = [];
|
||||
for (var l in coinsToSpend) {
|
||||
indices.add(l.index);
|
||||
}
|
||||
List<DartLelantusEntry> coinsToBeSpentOut = [];
|
||||
coinsToBeSpentOut.addAll(coinsToSpend);
|
||||
|
||||
return {"changeToMint": changeToMint, "coinsToSpend": coinsToBeSpentOut};
|
||||
}
|
||||
|
||||
Future<int> estimateJoinSplitFee(
|
||||
int spendAmount,
|
||||
) async {
|
||||
|
|
Loading…
Reference in a new issue