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

Function receive_offer

closingd/closingd.c:230–387  ·  view source on GitHub ↗

Returns fee they offered. */

Source from the content-addressed store, hash-verified

228
229/* Returns fee they offered. */
230static struct amount_sat
231receive_offer(struct per_peer_state *pps,
232 const struct chainparams *chainparams,
233 const struct channel_id *channel_id,
234 const struct pubkey funding_pubkey[NUM_SIDES],
235 const u8 *funding_wscript,
236 u32 *local_wallet_index,
237 const struct ext_key *local_wallet_ext_key,
238 u8 *scriptpubkey[NUM_SIDES],
239 const struct bitcoin_outpoint *funding,
240 struct amount_sat funding_sats,
241 const struct amount_sat out[NUM_SIDES],
242 enum side opener,
243 struct amount_sat our_dust_limit,
244 struct amount_sat min_fee_to_accept,
245 const struct bitcoin_outpoint *wrong_funding,
246 struct bitcoin_txid *closing_txid,
247 struct tlv_closing_signed_tlvs_fee_range **tlv_fees)
248{
249 u8 *msg;
250 struct channel_id their_channel_id;
251 struct amount_sat received_fee;
252 struct bitcoin_signature their_sig;
253 struct bitcoin_tx *tx;
254 struct tlv_closing_signed_tlvs *close_tlvs;
255
256 /* Wait for them to say something interesting */
257 do {
258 msg = closing_read_peer_msg(tmpctx, pps, channel_id);
259
260 /* BOLT #2:
261 *
262 * - upon reconnection:
263 * - MUST ignore any redundant `channel_ready` it receives.
264 */
265 /* This should only happen if we've made no commitments, but
266 * we don't have to check that: it's their problem. */
267 if (fromwire_peektype(msg) == WIRE_CHANNEL_READY)
268 msg = tal_free(msg);
269 /* BOLT #2:
270 * - if it has sent a previous `shutdown`:
271 * - MUST retransmit `shutdown`.
272 */
273 else if (fromwire_peektype(msg) == WIRE_SHUTDOWN)
274 msg = tal_free(msg);
275 /* channeld may have sent ping: ignore pong! */
276 else if (fromwire_peektype(msg) == WIRE_PONG)
277 msg = tal_free(msg);
278 } while (!msg);
279
280 their_sig.sighash_type = SIGHASH_ALL;
281 if (!fromwire_closing_signed(msg, msg, &their_channel_id,
282 &received_fee, &their_sig.s,
283 &close_tlvs))
284 peer_failed_warn(pps, channel_id,
285 "Expected closing_signed: %s",
286 tal_hex(tmpctx, msg));
287

Callers 2

do_quickcloseFunction · 0.85
mainFunction · 0.85

Calls 11

closing_read_peer_msgFunction · 0.85
tal_freeFunction · 0.85
peer_failed_warnFunction · 0.85
tal_hexFunction · 0.85
close_txFunction · 0.85
check_tx_sigFunction · 0.85
tell_master_their_offerFunction · 0.85
notifyFunction · 0.70
fromwire_peektypeFunction · 0.50
type_to_stringClass · 0.50
amount_sat_greater_eqFunction · 0.50

Tested by

no test coverage detected