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

Function revert_channel_state

openingd/dualopend.c:1665–1710  ·  view source on GitHub ↗

If there's a failure, we reset the state to the last * valid channel */

Source from the content-addressed store, hash-verified

1663/* If there's a failure, we reset the state to the last
1664 * valid channel */
1665static void revert_channel_state(struct state *state)
1666{
1667 struct tx_state *tx_state = state->tx_state;
1668 struct amount_sat total;
1669 struct amount_msat our_msats;
1670 enum side opener = state->our_role == TX_INITIATOR ? LOCAL : REMOTE;
1671 const struct channel_type *type;
1672
1673 /* We've already checked this */
1674 if (!amount_sat_add(&total, tx_state->opener_funding,
1675 tx_state->accepter_funding))
1676 abort();
1677
1678 /* We've already checked this */
1679 if (!amount_sat_to_msat(&our_msats,
1680 state->our_role == TX_INITIATOR ?
1681 tx_state->opener_funding :
1682 tx_state->accepter_funding))
1683 abort();
1684
1685 tal_free(state->channel);
1686 type = default_channel_type(NULL,
1687 state->our_features, state->their_features);
1688 state->channel = new_initial_channel(state,
1689 &state->channel_id,
1690 &tx_state->funding,
1691 state->minimum_depth,
1692 take(new_height_states(NULL, opener,
1693 &tx_state->blockheight)),
1694 tx_state->lease_expiry,
1695 total,
1696 our_msats,
1697 take(new_fee_states(
1698 NULL, opener,
1699 &state->feerate_per_kw_commitment)),
1700 &tx_state->localconf,
1701 &tx_state->remoteconf,
1702 &state->our_points,
1703 &state->their_points,
1704 &state->our_funding_pubkey,
1705 &state->their_funding_pubkey,
1706 take(type),
1707 feature_offered(state->their_features,
1708 OPT_LARGE_CHANNELS),
1709 opener);
1710}
1711
1712/* Returns NULL on negotation failure; reason given as *err_reason
1713 * In case that negotiation_aborted called, *err_reason set NULL */

Callers 2

accepter_commitsFunction · 0.85
opener_commitsFunction · 0.85

Calls 9

abortFunction · 0.85
tal_freeFunction · 0.85
default_channel_typeFunction · 0.85
new_initial_channelFunction · 0.85
new_fee_statesFunction · 0.85
amount_sat_addFunction · 0.50
amount_sat_to_msatFunction · 0.50
new_height_statesFunction · 0.50
feature_offeredFunction · 0.50

Tested by

no test coverage detected