Files
hash-wallet/cw_bitcoin/test/locktime_test.dart
T
ca00370ca4 Set anti-fee-sniping locktime (exact-tip) on bitcoin sends (#3385)
* Set anti-fee-sniping locktime on bitcoin sends

Current tip (exact-tip) via shared helper, wired into normal sends (path A) and payjoin/PSBT (path B). 0 when unsynced. Converges with the exact-tip cluster (payjoin-cli, ldk-node, Bull Bitcoin) and skips the ~10% backdate.

* Update cw_bitcoin/lib/locktime.dart

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>

* Update cw_bitcoin/lib/locktime.dart

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>

* Update cw_bitcoin/lib/locktime.dart [skip ci]

---------

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2026-08-19 12:43:59 +02:00

33 lines
931 B
Dart

import 'package:cw_bitcoin/locktime.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('antiFeeSnipingLocktime', () {
test('returns 0 when not synced', () {
expect(antiFeeSnipingLocktime(chainTip: 800000, synced: false), 0);
});
test('returns 0 when chainTip <= 0', () {
expect(antiFeeSnipingLocktime(chainTip: 0, synced: true), 0);
});
test('returns the current tip when synced', () {
expect(antiFeeSnipingLocktime(chainTip: 800000, synced: true), 800000);
});
});
group('locktimeToBytes', () {
test('encodes 0 as four zero bytes', () {
expect(locktimeToBytes(0), [0, 0, 0, 0]);
});
test('encodes a block height little-endian', () {
expect(locktimeToBytes(800000), [0x00, 0x35, 0x0C, 0x00]);
});
test('encodes max 32-bit value', () {
expect(locktimeToBytes(0xFFFFFFFF), [0xFF, 0xFF, 0xFF, 0xFF]);
});
});
}