Skip to content

Commit

Permalink
AND-9336, AND-9340: Fix Kaspa fee & utxo issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeeei committed Dec 11, 2024
1 parent 5068da7 commit 23a2f4d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class KaspaTransactionBuilder(
}

fun calculateChange(amount: BigDecimal, fee: BigDecimal, unspentOutputs: List<KaspaUnspentOutput>): BigDecimal {
val fullAmount = unspentOutputs.map { it.amount }.reduce { acc, number -> acc + number }
val fullAmount = unspentOutputs.sumOf { it.amount }
return fullAmount - (amount + fee)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal class KaspaWalletManager(
val unspentOutputCount = transactionBuilder.getUnspentsToSpendCount()

return if (unspentOutputCount == 0) {
Result.Failure(Exception("No unspent outputs found").toBlockchainSdkError()) // shouldn't happen
Result.Failure(BlockchainSdkError.Kaspa.ZeroUtxoError)
} else {
val source = wallet.address

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ sealed class BlockchainSdkError(
"Due to Kaspa limitations only $maxOutputs UTXOs can fit in a single transaction. This means you can only" +
" send ${maxAmount.toPlainString()}. You need to reduce the amount",
)
data object ZeroUtxoError : Kaspa(3)
}

sealed class Ton(
Expand Down

0 comments on commit 23a2f4d

Please sign in to comment.