mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
df-rbf: update channel data on depth reached
When the funding tx reaches depth, update the channel's data to the
"correct" funding transaction info from inflights (if necessary).
This will be necessary if:
- the transaction has been successfully RBF'd and
- the lesser fee transaction is the one successfully mined, OR
- the channel is in the process of being RBF'd
This commit is contained in:
@@ -1392,6 +1392,7 @@ cleanup:
|
||||
|
||||
void dualopen_tell_depth(struct subd *dualopend,
|
||||
struct channel *channel,
|
||||
const struct bitcoin_txid *txid,
|
||||
u32 depth)
|
||||
{
|
||||
const u8 *msg;
|
||||
@@ -1405,6 +1406,36 @@ void dualopen_tell_depth(struct subd *dualopend,
|
||||
/* Are we there yet? */
|
||||
if (to_go == 0) {
|
||||
assert(channel->scid);
|
||||
|
||||
/* Update the channel's info to the correct tx, if we need to */
|
||||
if (!bitcoin_txid_eq(&channel->funding_txid, txid)) {
|
||||
struct channel_inflight *inf;
|
||||
inf = channel_inflight_find(channel, txid);
|
||||
if (!inf) {
|
||||
channel_internal_error(channel,
|
||||
"Txid %s for channel"
|
||||
" not found in available inflights."
|
||||
" (peer %s)",
|
||||
type_to_string(tmpctx,
|
||||
struct bitcoin_txid,
|
||||
txid),
|
||||
type_to_string(tmpctx,
|
||||
struct node_id,
|
||||
&channel->peer->id));
|
||||
return;
|
||||
}
|
||||
|
||||
channel->funding_txid = inf->funding->txid;
|
||||
channel->funding_outnum = inf->funding->outnum;
|
||||
channel->funding = inf->funding->total_funds;
|
||||
channel->our_funds = inf->funding->our_funds;
|
||||
channel->psbt = clone_psbt(channel, inf->funding_psbt);
|
||||
channel->last_tx = tal_steal(channel, inf->last_tx);
|
||||
channel->last_sig = inf->last_sig;
|
||||
|
||||
wallet_channel_save(dualopend->ld->wallet, channel);
|
||||
/* FIXME: delete inflights */
|
||||
}
|
||||
msg = towire_dualopend_depth_reached(NULL, depth);
|
||||
subd_send_msg(dualopend, take(msg));
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user