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

Function accepter_commits

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

1712/* Returns NULL on negotation failure; reason given as *err_reason
1713 * In case that negotiation_aborted called, *err_reason set NULL */
1714static u8 *accepter_commits(struct state *state,
1715 struct tx_state *tx_state,
1716 struct amount_sat total,
1717 char **err_reason)
1718{
1719 struct wally_tx_output *direct_outputs[NUM_SIDES];
1720 struct bitcoin_tx *remote_commit, *local_commit;
1721 struct bitcoin_signature remote_sig, local_sig;
1722 secp256k1_ecdsa_signature *htlc_sigs;
1723 struct penalty_base *pbase;
1724 struct amount_msat our_msats;
1725 struct channel_id cid;
1726 const u8 *wscript;
1727 u8 *msg;
1728 char *error;
1729 const struct channel_type *type;
1730
1731 /* Find the funding transaction txid */
1732 psbt_txid(NULL, tx_state->psbt, &tx_state->funding.txid, NULL);
1733
1734 wscript = bitcoin_redeem_2of2(tmpctx,
1735 &state->our_funding_pubkey,
1736 &state->their_funding_pubkey);
1737
1738 /* Figure out the txout */
1739 if (!find_txout(tx_state->psbt,
1740 scriptpubkey_p2wsh(tmpctx, wscript),
1741 &tx_state->funding.n))
1742 open_err_warn(state,
1743 "Expected output %s not found on funding tx %s",
1744 tal_hex(tmpctx,
1745 scriptpubkey_p2wsh(tmpctx, wscript)),
1746 type_to_string(tmpctx, struct wally_psbt,
1747 tx_state->psbt));
1748
1749 /* Check tx funds are sane */
1750 error = check_balances(tmpctx, state, tx_state,
1751 tx_state->psbt,
1752 tx_state->feerate_per_kw_funding);
1753 if (error) {
1754 *err_reason = tal_fmt(tmpctx, "Insufficiently funded"
1755 " funding tx, %s. %s", error,
1756 type_to_string(tmpctx, struct wally_psbt,
1757 tx_state->psbt));
1758 return NULL;
1759 }
1760
1761 /* Wait for the peer to send us our commitment tx signature */
1762 msg = opening_negotiate_msg(tmpctx, state);
1763 if (!msg) {
1764 *err_reason = NULL;
1765 return NULL;
1766 }
1767
1768 remote_sig.sighash_type = SIGHASH_ALL;
1769 if (!fromwire_commitment_signed(tmpctx, msg, &cid,
1770 &remote_sig.s,
1771 &htlc_sigs))

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
open_err_warnFunction · 0.85
tal_hexFunction · 0.85
open_err_fatalFunction · 0.85
check_channel_idFunction · 0.85
default_channel_typeFunction · 0.85
tal_freeFunction · 0.85
new_initial_channelFunction · 0.85
new_fee_statesFunction · 0.85
initial_channel_txFunction · 0.85

Tested by

no test coverage detected