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

Function accepter_commits

openingd/dualopend.c:2156–2312  ·  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

2154/* Returns NULL on negotation failure; reason given as *err_reason
2155 * In case that negotiation_aborted called, *err_reason set NULL */
2156static u8 *accepter_commits(struct state *state,
2157 struct tx_state *tx_state,
2158 struct amount_sat total,
2159 char **err_reason)
2160{
2161 struct bitcoin_tx *local_commit;
2162 struct bitcoin_signature remote_sig;
2163 struct penalty_base *pbase;
2164 struct amount_msat our_msats;
2165 const u8 *wscript;
2166 u8 *msg, *commit_msg;
2167 char *error;
2168
2169 /* Find the funding transaction txid */
2170 psbt_txid(NULL, tx_state->psbt, &tx_state->funding.txid, NULL);
2171
2172 wscript = bitcoin_redeem_2of2(tmpctx,
2173 &state->our_funding_pubkey,
2174 &state->their_funding_pubkey);
2175
2176 /* Figure out the txout */
2177 if (!find_txout(tx_state->psbt,
2178 scriptpubkey_p2wsh(tmpctx, wscript),
2179 &tx_state->funding.n)) {
2180 *err_reason = tal_fmt(tmpctx, "Expected output %s not"
2181 " found on funding tx %s",
2182 tal_hex(tmpctx,
2183 scriptpubkey_p2wsh(tmpctx, wscript)),
2184 fmt_wally_psbt(tmpctx,
2185 tx_state->psbt));
2186 return NULL;
2187 }
2188
2189 /* Check tx funds are sane */
2190 *err_reason = check_balances(tmpctx, state, tx_state,
2191 tx_state->psbt,
2192 tx_state->feerate_per_kw_funding);
2193 if (*err_reason)
2194 return NULL;
2195
2196 if (!amount_sat_to_msat(&our_msats, tx_state->accepter_funding))
2197 status_failed(STATUS_FAIL_INTERNAL_ERROR,
2198 "Overflow converting accepter_funding "
2199 "to msats");
2200
2201 /*~ Report the channel parameters to the signer. */
2202 report_channel_hsmd(state, tx_state);
2203 tal_free(state->channel);
2204 state->channel = new_initial_channel(state,
2205 &state->channel_id,
2206 &tx_state->funding,
2207 state->minimum_depth,
2208 take(new_height_states(NULL, REMOTE,
2209 &tx_state->blockheight)),
2210
2211 tx_state->lease_expiry,
2212 total,
2213 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
feature_offeredFunction · 0.85

Tested by

no test coverage detected