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

Function receive_offer

closingd/closingd.c:240–405  ·  view source on GitHub ↗

Returns fee they offered. */

Source from the content-addressed store, hash-verified

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

Callers 2

do_quickcloseFunction · 0.85
mainFunction · 0.85

Calls 12

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

Tested by

no test coverage detected