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:1923–2036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1921}
1922
1923static void handle_peer_tx_sigs_msg(struct subd *dualopend,
1924 const u8 *msg)
1925{
1926 struct wally_psbt *psbt;
1927 const struct wally_tx *wtx;
1928 struct lightningd *ld = dualopend->ld;
1929 struct channel *channel = dualopend->channel;
1930 struct channel_inflight *inflight;
1931
1932 if (!fromwire_dualopend_funding_sigs(tmpctx, msg, &psbt)) {
1933 channel_internal_error(channel,
1934 "Bad DUALOPEND_FUNDING_SIGS: %s",
1935 tal_hex(tmpctx, msg));
1936 return;
1937 }
1938
1939 inflight = channel_current_inflight(channel);
1940 if (!inflight) {
1941 channel_internal_error(channel,
1942 "No inflight found for channel %s",
1943 type_to_string(tmpctx, struct channel,
1944 channel));
1945 return;
1946 }
1947
1948 /* Save that we've gotten their sigs. Sometimes
1949 * the peer doesn't send any sigs (no inputs), otherwise
1950 * we could just check the PSBT was finalized */
1951 inflight->remote_tx_sigs = true;
1952 tal_wally_start();
1953 if (wally_psbt_combine(inflight->funding_psbt, psbt) != WALLY_OK) {
1954 channel_internal_error(channel,
1955 "Unable to combine PSBTs: %s, %s",
1956 type_to_string(tmpctx,
1957 struct wally_psbt,
1958 inflight->funding_psbt),
1959 type_to_string(tmpctx,
1960 struct wally_psbt,
1961 psbt));
1962 tal_wally_end(inflight->funding_psbt);
1963 return;
1964 }
1965 tal_wally_end(inflight->funding_psbt);
1966 wallet_inflight_save(ld->wallet, inflight);
1967
1968 /* It's possible we haven't sent them our (empty) tx-sigs yet,
1969 * but we should be sending it soon... */
1970 if (psbt_finalize(cast_const(struct wally_psbt *,
1971 inflight->funding_psbt))
1972 && !inflight->tx_broadcast) {
1973 inflight->tx_broadcast = true;
1974
1975 /* Saves the now finalized version of the psbt */
1976 wallet_inflight_save(ld->wallet, inflight);
1977 wtx = psbt_final_tx(NULL, inflight->funding_psbt);
1978 if (!wtx) {
1979 channel_internal_error(channel,
1980 "Unable to extract final tx"

Callers 1

dual_opend_msgFunction · 0.85

Calls 15

tal_hexFunction · 0.85
channel_current_inflightFunction · 0.85
tal_wally_startFunction · 0.85
tal_wally_endFunction · 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

Tested by

no test coverage detected