Fix off-by-1 bug when preparing a transaction (#16)

This commit is contained in:
Kyle Fleming 2021-04-05 07:33:53 -10:00 committed by GitHub
parent 135894700e
commit 9cd66525a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ struct TransactionPreparer {
isGreaterThanValue: fee)
else {
logger.warning("failure - sumOfValues inputs: \(redacting: inputs) " +
"isGreaterThanValue fee: \(redacting: fee)")
"is less than or equal to fee: \(redacting: fee)")
serialQueue.async {
completion(.failure(.insufficientBalance()))
}
@ -97,9 +97,9 @@ struct TransactionPreparer {
}
guard UInt64.safeCompare(
sumOfValues: inputs.map { $0.value },
isGreaterThanSumOfValues: [amount.value, fee])
isGreaterThanOrEqualToSumOfValues: [amount.value, fee])
else {
logger.warning("sum of inputs is greater than amount + fee")
logger.warning("sum of inputs is less than amount + fee")
serialQueue.async {
completion(.failure(.insufficientBalance()))
}