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

Function handle_peer_tx_sigs_msg

lightningd/dual_open_control.c:2117–2229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2115}
2116
2117static void handle_peer_tx_sigs_msg(struct subd *dualopend,
2118 const u8 *msg)
2119{
2120 struct wally_psbt *psbt;
2121 const struct wally_tx *wtx;
2122 struct lightningd *ld = dualopend->ld;
2123 struct channel *channel = dualopend->channel;
2124 struct channel_inflight *inflight;
2125
2126 if (!fromwire_dualopend_funding_sigs(tmpctx, msg, &psbt)) {
2127 channel_internal_error(channel,
2128 "Bad DUALOPEND_FUNDING_SIGS: %s",
2129 tal_hex(tmpctx, msg));
2130 return;
2131 }
2132
2133 inflight = channel_current_inflight(channel);
2134 if (!inflight) {
2135 channel_internal_error(channel,
2136 "No inflight found for channel");
2137 return;
2138 }
2139
2140 /* Save that we've gotten their sigs. Sometimes
2141 * the peer doesn't send any sigs (no inputs), otherwise
2142 * we could just check the PSBT was finalized */
2143 inflight->remote_tx_sigs = true;
2144 tal_wally_start();
2145 if (wally_psbt_combine(inflight->funding_psbt, psbt) != WALLY_OK) {
2146 channel_internal_error(channel,
2147 "Unable to combine PSBTs: %s, %s",
2148 fmt_wally_psbt(tmpctx,
2149 inflight->funding_psbt),
2150 fmt_wally_psbt(tmpctx,
2151 psbt));
2152 tal_wally_end(inflight->funding_psbt);
2153 return;
2154 }
2155 tal_wally_end(inflight->funding_psbt);
2156 wallet_inflight_save(ld->wallet, inflight);
2157
2158 /* It's possible we haven't sent them our (empty) tx-sigs yet,
2159 * but we should be sending it soon... */
2160 if (psbt_finalize(cast_const(struct wally_psbt *,
2161 inflight->funding_psbt))
2162 && !inflight->tx_broadcast) {
2163 inflight->tx_broadcast = true;
2164
2165 /* Saves the now finalized version of the psbt */
2166 wallet_inflight_save(ld->wallet, inflight);
2167 wtx = psbt_final_tx(tmpctx, inflight->funding_psbt);
2168 if (!wtx) {
2169 channel_internal_error(channel,
2170 "Unable to extract final tx"
2171 " from PSBT %s",
2172 fmt_wally_psbt(tmpctx,
2173 inflight->funding_psbt));
2174 return;

Callers 1

dual_opend_msgFunction · 0.85

Calls 15

tal_hexFunction · 0.85
channel_current_inflightFunction · 0.85
tal_wally_startFunction · 0.85
fmt_wally_psbtFunction · 0.85
tal_wally_endFunction · 0.85
wallet_inflight_saveFunction · 0.85
psbt_finalizeFunction · 0.85
psbt_final_txFunction · 0.85
feerate_satisfiedFunction · 0.85
send_funding_txFunction · 0.85
channel_set_stateFunction · 0.85
notify_channel_openedFunction · 0.85

Tested by

no test coverage detected