MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_peer_tx_sigs_sent

Function handle_peer_tx_sigs_sent

lightningd/dual_open_control.c:1574–1666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1572}
1573
1574static void handle_peer_tx_sigs_sent(struct subd *dualopend,
1575 const int *fds,
1576 const u8 *msg)
1577{
1578 struct channel *channel = dualopend->channel;
1579 struct channel_inflight *inflight;
1580 const struct wally_tx *wtx;
1581
1582 if (!fromwire_dualopend_tx_sigs_sent(msg)) {
1583 channel_internal_error(channel,
1584 "Bad WIRE_DUALOPEND_TX_SIGS_SENT: %s",
1585 tal_hex(tmpctx, msg));
1586 return;
1587 }
1588
1589 inflight = channel_current_inflight(channel);
1590 if (!inflight) {
1591 channel_internal_error(channel,
1592 "No inflight found for channel %s",
1593 type_to_string(tmpctx, struct channel,
1594 channel));
1595 return;
1596 }
1597
1598 /* Once we've sent our sigs to the peer, we're fine
1599 * to broadcast the transaction, even if they haven't
1600 * sent us their tx-sigs yet. They're not allowed to
1601 * send us funding-locked until their tx-sigs has been
1602 * received, but that's no reason not to broadcast.
1603 * Note this only happens if we're the only input-er */
1604 if (psbt_finalize(inflight->funding_psbt) &&
1605 !inflight->tx_broadcast) {
1606 inflight->tx_broadcast = true;
1607
1608 wtx = psbt_final_tx(NULL, inflight->funding_psbt);
1609 if (!wtx) {
1610 channel_internal_error(channel,
1611 "Unable to extract final tx"
1612 " from PSBT %s",
1613 type_to_string(tmpctx,
1614 struct wally_psbt,
1615 inflight->funding_psbt));
1616 return;
1617 }
1618
1619 /* Saves the now finalized version of the psbt */
1620 wallet_inflight_save(dualopend->ld->wallet, inflight);
1621 send_funding_tx(channel, take(wtx));
1622
1623 /* Must be in an "init" state */
1624 assert(channel->state == DUALOPEND_OPEN_INIT
1625 || channel->state == DUALOPEND_AWAITING_LOCKIN);
1626
1627 channel_set_state(channel, channel->state,
1628 DUALOPEND_AWAITING_LOCKIN,
1629 REASON_UNKNOWN,
1630 "Sigs exchanged, waiting for lock-in");
1631

Callers 1

dual_opend_msgFunction · 0.85

Calls 12

tal_hexFunction · 0.85
channel_current_inflightFunction · 0.85
wallet_inflight_saveFunction · 0.85
send_funding_txFunction · 0.85
channel_set_stateFunction · 0.85
notify_channel_openedFunction · 0.85
feerate_satisfiedFunction · 0.85
channel_internal_errorFunction · 0.70
subd_send_msgFunction · 0.70
type_to_stringClass · 0.50
psbt_finalizeFunction · 0.50
psbt_final_txFunction · 0.50

Tested by

no test coverage detected