Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flutter_app/lib/services/blockbook_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class BlockbookService {
return rawFee.toInt();
}

return (rawFee * _satsPerCoin).ceil();
return (rawFee * _satsPerCoin).round();
}

if (rawFee is! String || rawFee.trim().isEmpty) return null;
Expand All @@ -206,7 +206,7 @@ class BlockbookService {

final asDouble = double.tryParse(trimmed);
if (asDouble != null && asDouble > 0) {
return asDouble >= 1 ? asDouble.toInt() : (asDouble * _satsPerCoin).ceil();
return asDouble >= 1 ? asDouble.toInt() : (asDouble * _satsPerCoin).round();
}

return null;
Expand Down
3 changes: 2 additions & 1 deletion flutter_app/test/blockbook_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void main() {
test('parses decimal fee response to satoshis per kb', () async {
final service = BlockbookService(
httpClient: MockClient((request) async {
expect(request.url.host, 'blockbook.reddcoin.com');
if (request.url.path.contains('/estimatefee/1')) {
return http.Response(json.encode({'result': '0.00012000'}), 200);
}
Expand All @@ -92,7 +93,7 @@ void main() {

final fee = await service.estimateFee(inputs: 1, outputs: 2);

expect(fee, 28);
expect(fee, 2712);
});

test('throws detailed error when node rejects broadcast', () async {
Expand Down