mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-11 09:04:21 +01:00
lightningd: expose default_locktime for wider usage.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1134,6 +1134,28 @@ u32 feerate_max(struct lightningd *ld, bool *unknown)
|
||||
return max * topo->ld->config.max_fee_multiplier;
|
||||
}
|
||||
|
||||
u32 default_locktime(const struct chain_topology *topo)
|
||||
{
|
||||
u32 locktime, current_height = get_block_height(topo);
|
||||
|
||||
/* Setting the locktime to the next block to be mined has multiple
|
||||
* benefits:
|
||||
* - anti fee-snipping (even if not yet likely)
|
||||
* - less distinguishable transactions (with this we create
|
||||
* general-purpose transactions which looks like bitcoind:
|
||||
* native segwit, nlocktime set to tip, and sequence set to
|
||||
* 0xFFFFFFFD by default. Other wallets are likely to implement
|
||||
* this too).
|
||||
*/
|
||||
locktime = current_height;
|
||||
|
||||
/* Eventually fuzz it too. */
|
||||
if (locktime > 100 && pseudorand(10) == 0)
|
||||
locktime -= pseudorand(100);
|
||||
|
||||
return locktime;
|
||||
}
|
||||
|
||||
/* On shutdown, channels get deleted last. That frees from our list, so
|
||||
* do it now instead. */
|
||||
static void destroy_chain_topology(struct chain_topology *topo)
|
||||
|
||||
@@ -196,6 +196,9 @@ u32 delayed_to_us_feerate(struct chain_topology *topo);
|
||||
u32 htlc_resolution_feerate(struct chain_topology *topo);
|
||||
u32 penalty_feerate(struct chain_topology *topo);
|
||||
|
||||
/* Usually we set nLocktime to tip (or recent) like bitcoind does */
|
||||
u32 default_locktime(const struct chain_topology *topo);
|
||||
|
||||
/**
|
||||
* broadcast_tx - Broadcast a single tx, and rebroadcast as reqd (copies tx).
|
||||
* @topo: topology
|
||||
|
||||
@@ -351,22 +351,9 @@ static struct command_result *finish_psbt(struct command *cmd,
|
||||
size_t change_outnum COMPILER_WANTS_INIT("gcc 9.4.0 -Og");
|
||||
u32 current_height = get_block_height(cmd->ld->topology);
|
||||
|
||||
/* Setting the locktime to the next block to be mined has multiple
|
||||
* benefits:
|
||||
* - anti fee-snipping (even if not yet likely)
|
||||
* - less distinguishable transactions (with this we create
|
||||
* general-purpose transactions which looks like bitcoind:
|
||||
* native segwit, nlocktime set to tip, and sequence set to
|
||||
* 0xFFFFFFFD by default. Other wallets are likely to implement
|
||||
* this too).
|
||||
*/
|
||||
if (!locktime) {
|
||||
locktime = tal(cmd, u32);
|
||||
*locktime = current_height;
|
||||
|
||||
/* Eventually fuzz it too. */
|
||||
if (*locktime > 100 && pseudorand(10) == 0)
|
||||
*locktime -= pseudorand(100);
|
||||
*locktime = default_locktime(cmd->ld->topology);
|
||||
}
|
||||
|
||||
psbt = psbt_using_utxos(cmd, cmd->ld->wallet, utxos,
|
||||
|
||||
Reference in New Issue
Block a user