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

Function accepter_commits

openingd/dualopend.c:2248–2404  ·  view source on GitHub ↗

Returns NULL on negotation failure; reason given as *err_reason * In case that negotiation_aborted called, *err_reason set NULL */

Source from the content-addressed store, hash-verified

2246/* Returns NULL on negotation failure; reason given as *err_reason
2247 * In case that negotiation_aborted called, *err_reason set NULL */
2248static u8 *accepter_commits(struct state *state,
2249 struct tx_state *tx_state,
2250 struct amount_sat total,
2251 char **err_reason)
2252{
2253 struct bitcoin_tx *local_commit;
2254 struct bitcoin_signature remote_sig;
2255 struct penalty_base *pbase;
2256 struct amount_msat our_msats;
2257 const u8 *wscript;
2258 u8 *msg, *commit_msg;
2259 char *error;
2260
2261 /* Find the funding transaction txid */
2262 psbt_txid(NULL, tx_state->psbt, &tx_state->funding.txid, NULL);
2263
2264 wscript = bitcoin_redeem_2of2(tmpctx,
2265 &state->our_funding_pubkey,
2266 &state->their_funding_pubkey);
2267
2268 /* Figure out the txout */
2269 if (!find_txout(tx_state->psbt,
2270 scriptpubkey_p2wsh(tmpctx, wscript),
2271 &tx_state->funding.n)) {
2272 *err_reason = tal_fmt(tmpctx, "Expected output %s not"
2273 " found on funding tx %s",
2274 tal_hex(tmpctx,
2275 scriptpubkey_p2wsh(tmpctx, wscript)),
2276 fmt_wally_psbt(tmpctx,
2277 tx_state->psbt));
2278 return NULL;
2279 }
2280
2281 /* Check tx funds are sane */
2282 *err_reason = check_balances(tmpctx, state, tx_state,
2283 tx_state->psbt,
2284 tx_state->feerate_per_kw_funding);
2285 if (*err_reason)
2286 return NULL;
2287
2288 if (!amount_sat_to_msat(&our_msats, tx_state->accepter_funding))
2289 status_failed(STATUS_FAIL_INTERNAL_ERROR,
2290 "Overflow converting accepter_funding "
2291 "to msats");
2292
2293 /*~ Report the channel parameters to the signer. */
2294 report_channel_hsmd(state, tx_state);
2295 tal_free(state->channel);
2296 state->channel = new_initial_channel(state,
2297 &state->channel_id,
2298 &tx_state->funding,
2299 state->minimum_depth,
2300 take(new_height_states(NULL, REMOTE,
2301 &tx_state->blockheight)),
2302
2303 tx_state->lease_expiry,
2304 total,
2305 our_msats,

Callers 2

accepter_startFunction · 0.85
rbf_wrap_upFunction · 0.85

Calls 15

psbt_txidFunction · 0.85
bitcoin_redeem_2of2Function · 0.85
find_txoutFunction · 0.85
scriptpubkey_p2wshFunction · 0.85
tal_hexFunction · 0.85
fmt_wally_psbtFunction · 0.85
report_channel_hsmdFunction · 0.85
tal_freeFunction · 0.85
new_initial_channelFunction · 0.85
new_height_statesFunction · 0.85
new_fee_statesFunction · 0.85
fromwire_peektypeFunction · 0.85

Tested by

no test coverage detected