As suggested by @TheBlueMatt and in discussion with 0x10w#1026 on discord, by default BDK should follow the anti-fee-sniping logic used by Bitcoin Core and Electrum to set the nLocktime when creating new transactions. This default nLocktime value should still be able to be overridden if the the existing TxParams.locktime parameter is set. See:
Bitcoin Core anti-fee-sniping code:
https://github.com/bitcoin/bitcoin/blob/6d859cbd794a36ed1c0c72324a4ec54d029b3d3b/src/wallet/spend.cpp#L591-L631
Electrum anti-fee-sniping code:
https://github.com/spesmilo/electrum/blob/7e6d65ec11c0dccfc24478471c5951d3ae586937/electrum/wallet.py#L211-L224
Currently BDK sets the default transaction nLocktime to 0. See:
|
// No nLockTime, default to 0 |
|
None => requirements.timelock.unwrap_or(0), |
As suggested by @TheBlueMatt and in discussion with 0x10w#1026 on discord, by default BDK should follow the anti-fee-sniping logic used by Bitcoin Core and Electrum to set the nLocktime when creating new transactions. This default nLocktime value should still be able to be overridden if the the existing
TxParams.locktimeparameter is set. See:Bitcoin Core anti-fee-sniping code:
https://github.com/bitcoin/bitcoin/blob/6d859cbd794a36ed1c0c72324a4ec54d029b3d3b/src/wallet/spend.cpp#L591-L631
Electrum anti-fee-sniping code:
https://github.com/spesmilo/electrum/blob/7e6d65ec11c0dccfc24478471c5951d3ae586937/electrum/wallet.py#L211-L224
Currently BDK sets the default transaction nLocktime to 0. See:
bdk/src/wallet/mod.rs
Lines 511 to 512 in b1346d4