mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
lease_rates: pass in 'lease_expiry' and 'csv' to commitments/channel
This commit is contained in:
parent
c9d2748081
commit
5989433810
@ -3568,6 +3568,7 @@ static void init_channel(struct peer *peer)
|
||||
&funding_txid,
|
||||
funding_txout,
|
||||
minimum_depth,
|
||||
0, /* FIXME: channel lease_expiry */
|
||||
funding,
|
||||
local_msat,
|
||||
take(fee_states),
|
||||
|
@ -95,6 +95,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
const struct bitcoin_txid *funding_txid,
|
||||
unsigned int funding_txout,
|
||||
u32 minimum_depth,
|
||||
u32 lease_expiry,
|
||||
struct amount_sat funding,
|
||||
struct amount_msat local_msat,
|
||||
const struct fee_states *fee_states,
|
||||
@ -113,6 +114,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
funding_txid,
|
||||
funding_txout,
|
||||
minimum_depth,
|
||||
lease_expiry,
|
||||
funding,
|
||||
local_msat,
|
||||
fee_states,
|
||||
|
@ -17,6 +17,7 @@ struct existing_htlc;
|
||||
* @funding_txid: The commitment transaction id.
|
||||
* @funding_txout: The commitment transaction output number.
|
||||
* @minimum_depth: The minimum confirmations needed for funding transaction.
|
||||
* @lease_expiry: The block the lease on this channel expires at; 0 if no lease.
|
||||
* @funding: The commitment transaction amount.
|
||||
* @local_msat: The amount for the local side (remainder goes to remote)
|
||||
* @fee_states: The fee update states.
|
||||
@ -37,6 +38,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
const struct bitcoin_txid *funding_txid,
|
||||
unsigned int funding_txout,
|
||||
u32 minimum_depth,
|
||||
u32 lease_expiry,
|
||||
struct amount_sat funding,
|
||||
struct amount_msat local_msat,
|
||||
const struct fee_states *fee_states,
|
||||
|
@ -481,6 +481,7 @@ int main(int argc, const char *argv[])
|
||||
derive_channel_id(&cid, &funding_txid, funding_output_index);
|
||||
lchannel = new_full_channel(tmpctx, &cid,
|
||||
&funding_txid, funding_output_index, 0,
|
||||
0, /* No channel lease */
|
||||
funding_amount, to_local,
|
||||
take(new_fee_states(NULL, LOCAL,
|
||||
&feerate_per_kw[LOCAL])),
|
||||
@ -492,6 +493,7 @@ int main(int argc, const char *argv[])
|
||||
false, false, LOCAL);
|
||||
rchannel = new_full_channel(tmpctx, &cid,
|
||||
&funding_txid, funding_output_index, 0,
|
||||
0, /* No channel lease */
|
||||
funding_amount, to_remote,
|
||||
take(new_fee_states(NULL, REMOTE,
|
||||
&feerate_per_kw[REMOTE])),
|
||||
|
@ -20,6 +20,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
||||
const struct bitcoin_txid *funding_txid,
|
||||
unsigned int funding_txout,
|
||||
u32 minimum_depth,
|
||||
u32 lease_expiry,
|
||||
struct amount_sat funding,
|
||||
struct amount_msat local_msatoshi,
|
||||
const struct fee_states *fee_states TAKES,
|
||||
@ -41,6 +42,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
||||
channel->funding_txout = funding_txout;
|
||||
channel->funding = funding;
|
||||
channel->minimum_depth = minimum_depth;
|
||||
channel->lease_expiry = lease_expiry;
|
||||
if (!amount_sat_sub_msat(&remote_msatoshi,
|
||||
channel->funding, local_msatoshi))
|
||||
return tal_free(channel);
|
||||
@ -120,7 +122,8 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
||||
0 ^ channel->commitment_number_obscurer,
|
||||
direct_outputs,
|
||||
side,
|
||||
0, /* FIXME: csv lock? */
|
||||
/* FIXME: is not the csv lock ?! */
|
||||
channel->lease_expiry,
|
||||
channel->option_anchor_outputs,
|
||||
err_reason);
|
||||
|
||||
|
@ -70,6 +70,9 @@ struct channel {
|
||||
|
||||
/* Is this using option_anchor_outputs? */
|
||||
bool option_anchor_outputs;
|
||||
|
||||
/* When the lease expires for the funds in this channel */
|
||||
u32 lease_expiry;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -79,6 +82,7 @@ struct channel {
|
||||
* @funding_txid: The commitment transaction id.
|
||||
* @funding_txout: The commitment transaction output number.
|
||||
* @minimum_depth: The minimum confirmations needed for funding transaction.
|
||||
* @lease_expiry: Block the lease expires
|
||||
* @funding_satoshis: The commitment transaction amount.
|
||||
* @local_msatoshi: The amount for the local side (remainder goes to remote)
|
||||
* @fee_states: The fee update states.
|
||||
@ -99,6 +103,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
||||
const struct bitcoin_txid *funding_txid,
|
||||
unsigned int funding_txout,
|
||||
u32 minimum_depth,
|
||||
u32 lease_expiry,
|
||||
struct amount_sat funding,
|
||||
struct amount_msat local_msatoshi,
|
||||
const struct fee_states *fee_states TAKES,
|
||||
|
@ -31,6 +31,7 @@ void towire_utxo(u8 **pptr, const struct utxo *utxo)
|
||||
if (utxo->close_info->commitment_point)
|
||||
towire_pubkey(pptr, utxo->close_info->commitment_point);
|
||||
towire_bool(pptr, utxo->close_info->option_anchor_outputs);
|
||||
towire_u32(pptr, utxo->close_info->csv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +60,7 @@ struct utxo *fromwire_utxo(const tal_t *ctx, const u8 **ptr, size_t *max)
|
||||
utxo->close_info->commitment_point = NULL;
|
||||
utxo->close_info->option_anchor_outputs
|
||||
= fromwire_bool(ptr, max);
|
||||
utxo->close_info->csv = fromwire_u32(ptr, max);
|
||||
} else {
|
||||
utxo->close_info = NULL;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ struct unilateral_close_info {
|
||||
bool option_anchor_outputs;
|
||||
/* NULL if this is an option_static_remotekey commitment */
|
||||
struct pubkey *commitment_point;
|
||||
u32 csv;
|
||||
};
|
||||
|
||||
/* Possible states for tracked outputs in the database. Not sure yet
|
||||
|
@ -394,6 +394,7 @@ int main(int argc, char *argv[])
|
||||
channel = new_full_channel(NULL,
|
||||
&cid,
|
||||
&funding_txid, funding_outnum, 1,
|
||||
0, /* Defaults to no lease */
|
||||
funding_amount,
|
||||
local_msat,
|
||||
take(new_fee_states(NULL, fee_payer,
|
||||
|
@ -391,7 +391,7 @@ static void sign_our_inputs(struct utxo **utxos, struct wally_psbt *psbt)
|
||||
const u8 *wscript
|
||||
= anchor_to_remote_redeem(tmpctx,
|
||||
&pubkey,
|
||||
1); /* FIXME: lease csv ? */
|
||||
utxo->close_info->csv);
|
||||
psbt_input_set_witscript(psbt, j, wscript);
|
||||
psbt_input_set_wit_utxo(psbt, j,
|
||||
scriptpubkey_p2wsh(psbt, wscript),
|
||||
|
@ -1672,6 +1672,7 @@ static void revert_channel_state(struct state *state)
|
||||
&tx_state->funding_txid,
|
||||
tx_state->funding_txout,
|
||||
state->minimum_depth,
|
||||
tx_state->lease_expiry,
|
||||
total,
|
||||
our_msats,
|
||||
take(new_fee_states(
|
||||
@ -1768,6 +1769,7 @@ static u8 *accepter_commits(struct state *state,
|
||||
&tx_state->funding_txid,
|
||||
tx_state->funding_txout,
|
||||
state->minimum_depth,
|
||||
tx_state->lease_expiry,
|
||||
total,
|
||||
our_msats,
|
||||
take(new_fee_states(
|
||||
@ -2356,6 +2358,7 @@ static u8 *opener_commits(struct state *state,
|
||||
&tx_state->funding_txid,
|
||||
tx_state->funding_txout,
|
||||
state->minimum_depth,
|
||||
tx_state->lease_expiry,
|
||||
total,
|
||||
our_msats,
|
||||
take(new_fee_states(NULL, LOCAL,
|
||||
@ -3732,6 +3735,7 @@ int main(int argc, char *argv[])
|
||||
&state->tx_state->funding_txid,
|
||||
state->tx_state->funding_txout,
|
||||
state->minimum_depth,
|
||||
state->tx_state->lease_expiry,
|
||||
total_funding,
|
||||
our_msat,
|
||||
fee_states,
|
||||
|
@ -510,6 +510,7 @@ static bool funder_finalize_channel_setup(struct state *state,
|
||||
&state->funding_txid,
|
||||
state->funding_txout,
|
||||
state->minimum_depth,
|
||||
0, /* No lease lock */
|
||||
state->funding,
|
||||
local_msat,
|
||||
take(new_fee_states(NULL, LOCAL,
|
||||
@ -1000,6 +1001,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
||||
&state->funding_txid,
|
||||
state->funding_txout,
|
||||
state->minimum_depth,
|
||||
0, /* No channel lease */
|
||||
state->funding,
|
||||
state->push_msat,
|
||||
take(new_fee_states(NULL, REMOTE,
|
||||
|
Loading…
Reference in New Issue
Block a user