mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
liquidity-ads: persist channel blockheight states to disk
Adds new tables to database, backfills, basically copies the fee_rates state machine for channeld.
This commit is contained in:
parent
a396c341cf
commit
265f960cfe
@ -35,6 +35,7 @@ CHANNELD_COMMON_OBJS := \
|
|||||||
common/billboard.o \
|
common/billboard.o \
|
||||||
common/bip32.o \
|
common/bip32.o \
|
||||||
common/blinding.o \
|
common/blinding.o \
|
||||||
|
common/blockheight_states.o \
|
||||||
common/channel_config.o \
|
common/channel_config.o \
|
||||||
common/channel_id.o \
|
common/channel_id.o \
|
||||||
common/crypto_state.o \
|
common/crypto_state.o \
|
||||||
|
@ -134,6 +134,9 @@ struct peer {
|
|||||||
/* The feerate we want. */
|
/* The feerate we want. */
|
||||||
u32 desired_feerate;
|
u32 desired_feerate;
|
||||||
|
|
||||||
|
/* Current blockheight */
|
||||||
|
u32 our_blockheight;
|
||||||
|
|
||||||
/* Announcement related information */
|
/* Announcement related information */
|
||||||
struct node_id node_ids[NUM_SIDES];
|
struct node_id node_ids[NUM_SIDES];
|
||||||
struct short_channel_id short_channel_ids[NUM_SIDES];
|
struct short_channel_id short_channel_ids[NUM_SIDES];
|
||||||
@ -837,6 +840,75 @@ static void handle_peer_feechange(struct peer *peer, const u8 *msg)
|
|||||||
status_debug("peer updated fee to %u", feerate);
|
status_debug("peer updated fee to %u", feerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_peer_blockheight_change(struct peer *peer, const u8 *msg)
|
||||||
|
{
|
||||||
|
struct channel_id channel_id;
|
||||||
|
u32 blockheight, current;
|
||||||
|
|
||||||
|
if (!fromwire_update_blockheight(msg, &channel_id, &blockheight))
|
||||||
|
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||||
|
"Bad update_blockheight %s",
|
||||||
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
|
/* BOLT- #2:
|
||||||
|
* A receiving node:
|
||||||
|
* ...
|
||||||
|
* - if the sender is not the initiator:
|
||||||
|
* - MUST fail the channel.
|
||||||
|
*/
|
||||||
|
if (peer->channel->opener != REMOTE)
|
||||||
|
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||||
|
"update_blockheight from non-opener?");
|
||||||
|
|
||||||
|
current = get_blockheight(peer->channel->blockheight_states,
|
||||||
|
peer->channel->opener, LOCAL);
|
||||||
|
|
||||||
|
status_debug("update_blockheight %u. last update height %u,"
|
||||||
|
" our current height %u",
|
||||||
|
blockheight, current, peer->our_blockheight);
|
||||||
|
|
||||||
|
/* BOLT- #2:
|
||||||
|
* A receiving node:
|
||||||
|
* - if the `update_blockheight` is less than the last
|
||||||
|
* received `blockheight`:
|
||||||
|
* - SHOULD fail the channel.
|
||||||
|
* ...
|
||||||
|
* - if `blockheight` is more than 1008 blocks behind
|
||||||
|
* the current blockheight:
|
||||||
|
* - SHOULD fail the channel
|
||||||
|
*/
|
||||||
|
/* Overflow check */
|
||||||
|
if (blockheight + 1008 < blockheight)
|
||||||
|
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||||
|
"blockheight + 1008 overflow (%u)",
|
||||||
|
blockheight);
|
||||||
|
|
||||||
|
/* If they're behind the last one they sent, we just warn and
|
||||||
|
* reconnect, as they might be catching up */
|
||||||
|
/* FIXME: track for how long they send backwards blockheight? */
|
||||||
|
if (blockheight < current)
|
||||||
|
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||||
|
"update_blockheight %u older than previous %u",
|
||||||
|
blockheight, current);
|
||||||
|
|
||||||
|
/* BOLT- #2:
|
||||||
|
* A receiving node:
|
||||||
|
* ...
|
||||||
|
* - if `blockheight` is more than 1008 blocks behind
|
||||||
|
* the current blockheight:
|
||||||
|
* - SHOULD fail the channel
|
||||||
|
*/
|
||||||
|
assert(blockheight < blockheight + 1008);
|
||||||
|
if (blockheight + 1008 < peer->our_blockheight)
|
||||||
|
peer_failed_err(peer->pps, &peer->channel_id,
|
||||||
|
"update_blockheight %u outside"
|
||||||
|
" permissible range", blockheight);
|
||||||
|
|
||||||
|
channel_update_blockheight(peer->channel, blockheight);
|
||||||
|
|
||||||
|
status_debug("peer updated blockheight to %u", blockheight);
|
||||||
|
}
|
||||||
|
|
||||||
static struct changed_htlc *changed_htlc_arr(const tal_t *ctx,
|
static struct changed_htlc *changed_htlc_arr(const tal_t *ctx,
|
||||||
const struct htlc **changed_htlcs)
|
const struct htlc **changed_htlcs)
|
||||||
{
|
{
|
||||||
@ -1140,6 +1212,41 @@ static bool want_fee_update(const struct peer *peer, u32 *target)
|
|||||||
return val != current;
|
return val != current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do we want to update blockheight? */
|
||||||
|
static bool want_blockheight_update(const struct peer *peer, u32 *height)
|
||||||
|
{
|
||||||
|
u32 last;
|
||||||
|
|
||||||
|
if (peer->channel->opener != LOCAL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (peer->channel->lease_expiry == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if EXPERIMENTAL_FEATURES
|
||||||
|
/* No fee update while quiescing! */
|
||||||
|
if (peer->stfu)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
/* What's the current blockheight */
|
||||||
|
last = get_blockheight(peer->channel->blockheight_states,
|
||||||
|
peer->channel->opener, LOCAL);
|
||||||
|
|
||||||
|
if (peer->our_blockheight < last) {
|
||||||
|
status_broken("current blockheight %u less than last %u",
|
||||||
|
peer->our_blockheight, last);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (peer->our_blockheight == last)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (height)
|
||||||
|
*height = peer->our_blockheight;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void send_commit(struct peer *peer)
|
static void send_commit(struct peer *peer)
|
||||||
{
|
{
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
@ -1150,6 +1257,7 @@ static void send_commit(struct peer *peer)
|
|||||||
const struct htlc **htlc_map;
|
const struct htlc **htlc_map;
|
||||||
struct wally_tx_output *direct_outputs[NUM_SIDES];
|
struct wally_tx_output *direct_outputs[NUM_SIDES];
|
||||||
struct penalty_base *pbase;
|
struct penalty_base *pbase;
|
||||||
|
u32 our_blockheight;
|
||||||
u32 feerate_target;
|
u32 feerate_target;
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
@ -1218,6 +1326,22 @@ static void send_commit(struct peer *peer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (want_blockheight_update(peer, &our_blockheight)) {
|
||||||
|
if (blockheight_changes_done(peer->channel->blockheight_states,
|
||||||
|
false)) {
|
||||||
|
u8 *msg;
|
||||||
|
|
||||||
|
channel_update_blockheight(peer->channel,
|
||||||
|
our_blockheight);
|
||||||
|
|
||||||
|
msg = towire_update_blockheight(NULL,
|
||||||
|
&peer->channel_id,
|
||||||
|
our_blockheight);
|
||||||
|
|
||||||
|
sync_crypto_write(peer->pps, take(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
* A sending node:
|
* A sending node:
|
||||||
@ -1226,9 +1350,13 @@ static void send_commit(struct peer *peer)
|
|||||||
*/
|
*/
|
||||||
changed_htlcs = tal_arr(tmpctx, const struct htlc *, 0);
|
changed_htlcs = tal_arr(tmpctx, const struct htlc *, 0);
|
||||||
if (!channel_sending_commit(peer->channel, &changed_htlcs)) {
|
if (!channel_sending_commit(peer->channel, &changed_htlcs)) {
|
||||||
status_debug("Can't send commit: nothing to send, feechange %s (%s)",
|
status_debug("Can't send commit: nothing to send,"
|
||||||
|
" feechange %s (%s)"
|
||||||
|
" blockheight %s (%s)",
|
||||||
want_fee_update(peer, NULL) ? "wanted": "not wanted",
|
want_fee_update(peer, NULL) ? "wanted": "not wanted",
|
||||||
type_to_string(tmpctx, struct fee_states, peer->channel->fee_states));
|
type_to_string(tmpctx, struct fee_states, peer->channel->fee_states),
|
||||||
|
want_blockheight_update(peer, NULL) ? "wanted" : "not wanted",
|
||||||
|
type_to_string(tmpctx, struct height_states, peer->channel->blockheight_states));
|
||||||
|
|
||||||
/* Covers the case where we've just been told to shutdown. */
|
/* Covers the case where we've just been told to shutdown. */
|
||||||
maybe_send_shutdown(peer);
|
maybe_send_shutdown(peer);
|
||||||
@ -2099,8 +2227,8 @@ static void peer_in(struct peer *peer, const u8 *msg)
|
|||||||
handle_peer_feechange(peer, msg);
|
handle_peer_feechange(peer, msg);
|
||||||
return;
|
return;
|
||||||
case WIRE_UPDATE_BLOCKHEIGHT:
|
case WIRE_UPDATE_BLOCKHEIGHT:
|
||||||
/* FIXME: do this! */
|
handle_peer_blockheight_change(peer, msg);
|
||||||
break;
|
return;
|
||||||
case WIRE_REVOKE_AND_ACK:
|
case WIRE_REVOKE_AND_ACK:
|
||||||
handle_peer_revoke_and_ack(peer, msg);
|
handle_peer_revoke_and_ack(peer, msg);
|
||||||
return;
|
return;
|
||||||
@ -3172,6 +3300,49 @@ static void handle_feerates(struct peer *peer, const u8 *inmsg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_blockheight(struct peer *peer, const u8 *inmsg)
|
||||||
|
{
|
||||||
|
u32 blockheight;
|
||||||
|
|
||||||
|
if (!fromwire_channeld_blockheight(inmsg, &blockheight))
|
||||||
|
master_badmsg(WIRE_CHANNELD_BLOCKHEIGHT, inmsg);
|
||||||
|
|
||||||
|
/* Save it, so we know */
|
||||||
|
peer->our_blockheight = blockheight;
|
||||||
|
if (peer->channel->opener == LOCAL)
|
||||||
|
start_commit_timer(peer);
|
||||||
|
else {
|
||||||
|
u32 peer_height = get_blockheight(peer->channel->blockheight_states,
|
||||||
|
peer->channel->opener,
|
||||||
|
REMOTE);
|
||||||
|
/* BOLT- #2:
|
||||||
|
* The node _not responsible_ for initiating the channel:
|
||||||
|
* ...
|
||||||
|
* - if last received `blockheight` is > 1008 behind
|
||||||
|
* currently known blockheight:
|
||||||
|
* - SHOULD fail he channel
|
||||||
|
*/
|
||||||
|
assert(peer_height + 1008 > peer_height);
|
||||||
|
if (peer_height + 1008 < blockheight)
|
||||||
|
peer_failed_err(peer->pps, &peer->channel_id,
|
||||||
|
"Peer is too far behind, terminating"
|
||||||
|
" leased channel. Our current"
|
||||||
|
" %u, theirs %u",
|
||||||
|
blockheight, peer_height);
|
||||||
|
/* We're behind them... what do. It's possible they're lying,
|
||||||
|
* but if we're in a lease this is actually in our favor so
|
||||||
|
* we log it but otherwise continue on unchanged */
|
||||||
|
if (peer_height > blockheight
|
||||||
|
&& peer_height > blockheight + 100)
|
||||||
|
status_unusual("Peer reporting we've fallen %u"
|
||||||
|
" blocks behind. Our height %u,"
|
||||||
|
" their height %u",
|
||||||
|
peer_height - blockheight,
|
||||||
|
blockheight, peer_height);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_specific_feerates(struct peer *peer, const u8 *inmsg)
|
static void handle_specific_feerates(struct peer *peer, const u8 *inmsg)
|
||||||
{
|
{
|
||||||
u32 base_old = peer->fee_base;
|
u32 base_old = peer->fee_base;
|
||||||
@ -3350,6 +3521,11 @@ static void req_in(struct peer *peer, const u8 *msg)
|
|||||||
return;
|
return;
|
||||||
handle_feerates(peer, msg);
|
handle_feerates(peer, msg);
|
||||||
return;
|
return;
|
||||||
|
case WIRE_CHANNELD_BLOCKHEIGHT:
|
||||||
|
if (handle_master_request_later(peer, msg))
|
||||||
|
return;
|
||||||
|
handle_blockheight(peer, msg);
|
||||||
|
return;
|
||||||
case WIRE_CHANNELD_FULFILL_HTLC:
|
case WIRE_CHANNELD_FULFILL_HTLC:
|
||||||
if (handle_master_request_later(peer, msg))
|
if (handle_master_request_later(peer, msg))
|
||||||
return;
|
return;
|
||||||
@ -3438,7 +3614,8 @@ static void init_channel(struct peer *peer)
|
|||||||
u8 *fwd_msg;
|
u8 *fwd_msg;
|
||||||
const u8 *msg;
|
const u8 *msg;
|
||||||
struct fee_states *fee_states;
|
struct fee_states *fee_states;
|
||||||
u32 minimum_depth;
|
struct height_states *blockheight_states;
|
||||||
|
u32 minimum_depth, lease_expiry;
|
||||||
struct secret last_remote_per_commit_secret;
|
struct secret last_remote_per_commit_secret;
|
||||||
secp256k1_ecdsa_signature *remote_ann_node_sig;
|
secp256k1_ecdsa_signature *remote_ann_node_sig;
|
||||||
secp256k1_ecdsa_signature *remote_ann_bitcoin_sig;
|
secp256k1_ecdsa_signature *remote_ann_bitcoin_sig;
|
||||||
@ -3459,6 +3636,9 @@ static void init_channel(struct peer *peer)
|
|||||||
&funding_txid, &funding_txout,
|
&funding_txid, &funding_txout,
|
||||||
&funding,
|
&funding,
|
||||||
&minimum_depth,
|
&minimum_depth,
|
||||||
|
&peer->our_blockheight,
|
||||||
|
&blockheight_states,
|
||||||
|
&lease_expiry,
|
||||||
&conf[LOCAL], &conf[REMOTE],
|
&conf[LOCAL], &conf[REMOTE],
|
||||||
&fee_states,
|
&fee_states,
|
||||||
&peer->feerate_min,
|
&peer->feerate_min,
|
||||||
@ -3529,7 +3709,8 @@ static void init_channel(struct peer *peer)
|
|||||||
" next_idx_local = %"PRIu64
|
" next_idx_local = %"PRIu64
|
||||||
" next_idx_remote = %"PRIu64
|
" next_idx_remote = %"PRIu64
|
||||||
" revocations_received = %"PRIu64
|
" revocations_received = %"PRIu64
|
||||||
" feerates %s range %u-%u",
|
" feerates %s range %u-%u"
|
||||||
|
" blockheights %s, our current %u",
|
||||||
side_to_str(opener),
|
side_to_str(opener),
|
||||||
type_to_string(tmpctx, struct pubkey,
|
type_to_string(tmpctx, struct pubkey,
|
||||||
&peer->remote_per_commit),
|
&peer->remote_per_commit),
|
||||||
@ -3538,7 +3719,9 @@ static void init_channel(struct peer *peer)
|
|||||||
peer->next_index[LOCAL], peer->next_index[REMOTE],
|
peer->next_index[LOCAL], peer->next_index[REMOTE],
|
||||||
peer->revocations_received,
|
peer->revocations_received,
|
||||||
type_to_string(tmpctx, struct fee_states, fee_states),
|
type_to_string(tmpctx, struct fee_states, fee_states),
|
||||||
peer->feerate_min, peer->feerate_max);
|
peer->feerate_min, peer->feerate_max,
|
||||||
|
type_to_string(tmpctx, struct height_states, blockheight_states),
|
||||||
|
peer->our_blockheight);
|
||||||
|
|
||||||
status_debug("option_static_remotekey = %u", option_static_remotekey);
|
status_debug("option_static_remotekey = %u", option_static_remotekey);
|
||||||
|
|
||||||
@ -3568,7 +3751,8 @@ static void init_channel(struct peer *peer)
|
|||||||
&funding_txid,
|
&funding_txid,
|
||||||
funding_txout,
|
funding_txout,
|
||||||
minimum_depth,
|
minimum_depth,
|
||||||
0, /* FIXME: channel lease_expiry */
|
take(blockheight_states),
|
||||||
|
lease_expiry,
|
||||||
funding,
|
funding,
|
||||||
local_msat,
|
local_msat,
|
||||||
take(fee_states),
|
take(fee_states),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <bitcoin/psbt.h>
|
#include <bitcoin/psbt.h>
|
||||||
#include <bitcoin/tx.h>
|
#include <bitcoin/tx.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/cryptomsg.h>
|
#include <common/cryptomsg.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/channel_id.h>
|
#include <common/channel_id.h>
|
||||||
@ -17,6 +18,9 @@ msgdata,channeld_init,funding_txid,bitcoin_txid,
|
|||||||
msgdata,channeld_init,funding_txout,u16,
|
msgdata,channeld_init,funding_txout,u16,
|
||||||
msgdata,channeld_init,funding_satoshi,amount_sat,
|
msgdata,channeld_init,funding_satoshi,amount_sat,
|
||||||
msgdata,channeld_init,minimum_depth,u32,
|
msgdata,channeld_init,minimum_depth,u32,
|
||||||
|
msgdata,channeld_init,our_blockheight,u32,
|
||||||
|
msgdata,channeld_init,blockheight_states,height_states,
|
||||||
|
msgdata,channeld_init,lease_expiry,u32,
|
||||||
msgdata,channeld_init,our_config,channel_config,
|
msgdata,channeld_init,our_config,channel_config,
|
||||||
msgdata,channeld_init,their_config,channel_config,
|
msgdata,channeld_init,their_config,channel_config,
|
||||||
msgdata,channeld_init,fee_states,fee_states,
|
msgdata,channeld_init,fee_states,fee_states,
|
||||||
@ -227,3 +231,7 @@ msgtype,channeld_dev_quiesce_reply,1109
|
|||||||
# Tell master we're upgrading the commitment tx.
|
# Tell master we're upgrading the commitment tx.
|
||||||
msgtype,channeld_upgraded,1011
|
msgtype,channeld_upgraded,1011
|
||||||
msgdata,channeld_upgraded,option_static_remotekey,bool,
|
msgdata,channeld_upgraded,option_static_remotekey,bool,
|
||||||
|
|
||||||
|
# Tell peer about our latest and greatest blockheight.
|
||||||
|
msgtype,channeld_blockheight,1012
|
||||||
|
msgdata,channeld_blockheight,blockheight,u32,
|
||||||
|
Can't render this file because it has a wrong number of fields in line 13.
|
36
channeld/channeld_wiregen.c
generated
36
channeld/channeld_wiregen.c
generated
@ -49,6 +49,7 @@ const char *channeld_wire_name(int e)
|
|||||||
case WIRE_CHANNELD_DEV_QUIESCE: return "WIRE_CHANNELD_DEV_QUIESCE";
|
case WIRE_CHANNELD_DEV_QUIESCE: return "WIRE_CHANNELD_DEV_QUIESCE";
|
||||||
case WIRE_CHANNELD_DEV_QUIESCE_REPLY: return "WIRE_CHANNELD_DEV_QUIESCE_REPLY";
|
case WIRE_CHANNELD_DEV_QUIESCE_REPLY: return "WIRE_CHANNELD_DEV_QUIESCE_REPLY";
|
||||||
case WIRE_CHANNELD_UPGRADED: return "WIRE_CHANNELD_UPGRADED";
|
case WIRE_CHANNELD_UPGRADED: return "WIRE_CHANNELD_UPGRADED";
|
||||||
|
case WIRE_CHANNELD_BLOCKHEIGHT: return "WIRE_CHANNELD_BLOCKHEIGHT";
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
|
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
|
||||||
@ -87,6 +88,7 @@ bool channeld_wire_is_defined(u16 type)
|
|||||||
case WIRE_CHANNELD_DEV_QUIESCE:;
|
case WIRE_CHANNELD_DEV_QUIESCE:;
|
||||||
case WIRE_CHANNELD_DEV_QUIESCE_REPLY:;
|
case WIRE_CHANNELD_DEV_QUIESCE_REPLY:;
|
||||||
case WIRE_CHANNELD_UPGRADED:;
|
case WIRE_CHANNELD_UPGRADED:;
|
||||||
|
case WIRE_CHANNELD_BLOCKHEIGHT:;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -98,7 +100,7 @@ bool channeld_wire_is_defined(u16 type)
|
|||||||
|
|
||||||
/* WIRE: CHANNELD_INIT */
|
/* WIRE: CHANNELD_INIT */
|
||||||
/* Begin! (passes gossipd-client fd) */
|
/* Begin! (passes gossipd-client fd) */
|
||||||
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases, const u8 *reestablish_only)
|
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, u32 our_blockheight, const struct height_states *blockheight_states, u32 lease_expiry, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases, const u8 *reestablish_only)
|
||||||
{
|
{
|
||||||
u16 num_last_sent_commit = tal_count(last_sent_commit);
|
u16 num_last_sent_commit = tal_count(last_sent_commit);
|
||||||
u16 num_existing_htlcs = tal_count(htlcs);
|
u16 num_existing_htlcs = tal_count(htlcs);
|
||||||
@ -118,6 +120,9 @@ u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams
|
|||||||
towire_u16(&p, funding_txout);
|
towire_u16(&p, funding_txout);
|
||||||
towire_amount_sat(&p, funding_satoshi);
|
towire_amount_sat(&p, funding_satoshi);
|
||||||
towire_u32(&p, minimum_depth);
|
towire_u32(&p, minimum_depth);
|
||||||
|
towire_u32(&p, our_blockheight);
|
||||||
|
towire_height_states(&p, blockheight_states);
|
||||||
|
towire_u32(&p, lease_expiry);
|
||||||
towire_channel_config(&p, our_config);
|
towire_channel_config(&p, our_config);
|
||||||
towire_channel_config(&p, their_config);
|
towire_channel_config(&p, their_config);
|
||||||
towire_fee_states(&p, fee_states);
|
towire_fee_states(&p, fee_states);
|
||||||
@ -192,7 +197,7 @@ u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams
|
|||||||
|
|
||||||
return memcheck(p, tal_count(p));
|
return memcheck(p, tal_count(p));
|
||||||
}
|
}
|
||||||
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases, u8 **reestablish_only)
|
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, u32 *our_blockheight, struct height_states **blockheight_states, u32 *lease_expiry, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases, u8 **reestablish_only)
|
||||||
{
|
{
|
||||||
u16 num_last_sent_commit;
|
u16 num_last_sent_commit;
|
||||||
u16 num_existing_htlcs;
|
u16 num_existing_htlcs;
|
||||||
@ -215,6 +220,9 @@ bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainp
|
|||||||
*funding_txout = fromwire_u16(&cursor, &plen);
|
*funding_txout = fromwire_u16(&cursor, &plen);
|
||||||
*funding_satoshi = fromwire_amount_sat(&cursor, &plen);
|
*funding_satoshi = fromwire_amount_sat(&cursor, &plen);
|
||||||
*minimum_depth = fromwire_u32(&cursor, &plen);
|
*minimum_depth = fromwire_u32(&cursor, &plen);
|
||||||
|
*our_blockheight = fromwire_u32(&cursor, &plen);
|
||||||
|
*blockheight_states = fromwire_height_states(ctx, &cursor, &plen);
|
||||||
|
*lease_expiry = fromwire_u32(&cursor, &plen);
|
||||||
fromwire_channel_config(&cursor, &plen, our_config);
|
fromwire_channel_config(&cursor, &plen, our_config);
|
||||||
fromwire_channel_config(&cursor, &plen, their_config);
|
fromwire_channel_config(&cursor, &plen, their_config);
|
||||||
*fee_states = fromwire_fee_states(ctx, &cursor, &plen);
|
*fee_states = fromwire_fee_states(ctx, &cursor, &plen);
|
||||||
@ -1145,4 +1153,26 @@ bool fromwire_channeld_upgraded(const void *p, bool *option_static_remotekey)
|
|||||||
*option_static_remotekey = fromwire_bool(&cursor, &plen);
|
*option_static_remotekey = fromwire_bool(&cursor, &plen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:7fe345eb02876c231759ec37daba697e85ac3a43137e4b7cb67d136587e2bda5
|
|
||||||
|
/* WIRE: CHANNELD_BLOCKHEIGHT */
|
||||||
|
/* Tell peer about our latest and greatest blockheight. */
|
||||||
|
u8 *towire_channeld_blockheight(const tal_t *ctx, u32 blockheight)
|
||||||
|
{
|
||||||
|
u8 *p = tal_arr(ctx, u8, 0);
|
||||||
|
|
||||||
|
towire_u16(&p, WIRE_CHANNELD_BLOCKHEIGHT);
|
||||||
|
towire_u32(&p, blockheight);
|
||||||
|
|
||||||
|
return memcheck(p, tal_count(p));
|
||||||
|
}
|
||||||
|
bool fromwire_channeld_blockheight(const void *p, u32 *blockheight)
|
||||||
|
{
|
||||||
|
const u8 *cursor = p;
|
||||||
|
size_t plen = tal_count(p);
|
||||||
|
|
||||||
|
if (fromwire_u16(&cursor, &plen) != WIRE_CHANNELD_BLOCKHEIGHT)
|
||||||
|
return false;
|
||||||
|
*blockheight = fromwire_u32(&cursor, &plen);
|
||||||
|
return cursor != NULL;
|
||||||
|
}
|
||||||
|
// SHA256STAMP:40a8d4ea75d57eeddfb5cc648a9ca3e3914dfe500a6054b6a6942f4023a17d82
|
||||||
|
14
channeld/channeld_wiregen.h
generated
14
channeld/channeld_wiregen.h
generated
@ -9,6 +9,7 @@
|
|||||||
#include <wire/wire.h>
|
#include <wire/wire.h>
|
||||||
#include <bitcoin/psbt.h>
|
#include <bitcoin/psbt.h>
|
||||||
#include <bitcoin/tx.h>
|
#include <bitcoin/tx.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/cryptomsg.h>
|
#include <common/cryptomsg.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/channel_id.h>
|
#include <common/channel_id.h>
|
||||||
@ -75,6 +76,8 @@ enum channeld_wire {
|
|||||||
WIRE_CHANNELD_DEV_QUIESCE_REPLY = 1109,
|
WIRE_CHANNELD_DEV_QUIESCE_REPLY = 1109,
|
||||||
/* Tell master we're upgrading the commitment tx. */
|
/* Tell master we're upgrading the commitment tx. */
|
||||||
WIRE_CHANNELD_UPGRADED = 1011,
|
WIRE_CHANNELD_UPGRADED = 1011,
|
||||||
|
/* Tell peer about our latest and greatest blockheight. */
|
||||||
|
WIRE_CHANNELD_BLOCKHEIGHT = 1012,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *channeld_wire_name(int e);
|
const char *channeld_wire_name(int e);
|
||||||
@ -91,8 +94,8 @@ bool channeld_wire_is_defined(u16 type);
|
|||||||
|
|
||||||
/* WIRE: CHANNELD_INIT */
|
/* WIRE: CHANNELD_INIT */
|
||||||
/* Begin! (passes gossipd-client fd) */
|
/* Begin! (passes gossipd-client fd) */
|
||||||
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases, const u8 *reestablish_only);
|
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, u32 our_blockheight, const struct height_states *blockheight_states, u32 lease_expiry, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases, const u8 *reestablish_only);
|
||||||
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases, u8 **reestablish_only);
|
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, u32 *our_blockheight, struct height_states **blockheight_states, u32 *lease_expiry, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases, u8 **reestablish_only);
|
||||||
|
|
||||||
/* WIRE: CHANNELD_FUNDING_DEPTH */
|
/* WIRE: CHANNELD_FUNDING_DEPTH */
|
||||||
/* master->channeld funding hit new depth(funding locked if >= lock depth) */
|
/* master->channeld funding hit new depth(funding locked if >= lock depth) */
|
||||||
@ -230,6 +233,11 @@ bool fromwire_channeld_dev_quiesce_reply(const void *p);
|
|||||||
u8 *towire_channeld_upgraded(const tal_t *ctx, bool option_static_remotekey);
|
u8 *towire_channeld_upgraded(const tal_t *ctx, bool option_static_remotekey);
|
||||||
bool fromwire_channeld_upgraded(const void *p, bool *option_static_remotekey);
|
bool fromwire_channeld_upgraded(const void *p, bool *option_static_remotekey);
|
||||||
|
|
||||||
|
/* WIRE: CHANNELD_BLOCKHEIGHT */
|
||||||
|
/* Tell peer about our latest and greatest blockheight. */
|
||||||
|
u8 *towire_channeld_blockheight(const tal_t *ctx, u32 blockheight);
|
||||||
|
bool fromwire_channeld_blockheight(const void *p, u32 *blockheight);
|
||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */
|
#endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */
|
||||||
// SHA256STAMP:7fe345eb02876c231759ec37daba697e85ac3a43137e4b7cb67d136587e2bda5
|
// SHA256STAMP:40a8d4ea75d57eeddfb5cc648a9ca3e3914dfe500a6054b6a6942f4023a17d82
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <channeld/commit_tx.h>
|
#include <channeld/commit_tx.h>
|
||||||
#include <channeld/full_channel.h>
|
#include <channeld/full_channel.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
#include <common/htlc.h>
|
#include <common/htlc.h>
|
||||||
@ -95,6 +96,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
|||||||
const struct bitcoin_txid *funding_txid,
|
const struct bitcoin_txid *funding_txid,
|
||||||
unsigned int funding_txout,
|
unsigned int funding_txout,
|
||||||
u32 minimum_depth,
|
u32 minimum_depth,
|
||||||
|
const struct height_states *blockheight_states,
|
||||||
u32 lease_expiry,
|
u32 lease_expiry,
|
||||||
struct amount_sat funding,
|
struct amount_sat funding,
|
||||||
struct amount_msat local_msat,
|
struct amount_msat local_msat,
|
||||||
@ -114,6 +116,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
|||||||
funding_txid,
|
funding_txid,
|
||||||
funding_txout,
|
funding_txout,
|
||||||
minimum_depth,
|
minimum_depth,
|
||||||
|
blockheight_states,
|
||||||
lease_expiry,
|
lease_expiry,
|
||||||
funding,
|
funding,
|
||||||
local_msat,
|
local_msat,
|
||||||
@ -979,6 +982,34 @@ static bool fee_incstate(struct channel *channel,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool blockheight_incstate(struct channel *channel,
|
||||||
|
enum side sidechanged,
|
||||||
|
enum htlc_state hstate)
|
||||||
|
{
|
||||||
|
int preflags, postflags;
|
||||||
|
|
||||||
|
preflags = htlc_state_flags(hstate);
|
||||||
|
postflags = htlc_state_flags(hstate + 1);
|
||||||
|
|
||||||
|
/* You can't change sides. */
|
||||||
|
assert((preflags & (HTLC_LOCAL_F_OWNER|HTLC_REMOTE_F_OWNER))
|
||||||
|
== (postflags & (HTLC_LOCAL_F_OWNER|HTLC_REMOTE_F_OWNER)));
|
||||||
|
|
||||||
|
/* These only advance through ADDING states. */
|
||||||
|
if (!(htlc_state_flags(hstate) & HTLC_ADDING))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!inc_height_state(channel->blockheight_states, hstate))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
status_debug("Blockheight: %s->%s %s now %u",
|
||||||
|
htlc_state_name(hstate),
|
||||||
|
htlc_state_name(hstate+1),
|
||||||
|
side_to_str(sidechanged),
|
||||||
|
*channel->blockheight_states->height[hstate+1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns flags which were changed. */
|
/* Returns flags which were changed. */
|
||||||
static int change_htlcs(struct channel *channel,
|
static int change_htlcs(struct channel *channel,
|
||||||
enum side sidechanged,
|
enum side sidechanged,
|
||||||
@ -1022,11 +1053,16 @@ static int change_htlcs(struct channel *channel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update fees (do backwards, to avoid double-increment!). */
|
/* Update fees and blockheight (do backwards, to avoid
|
||||||
|
* double-increment!). */
|
||||||
for (i = n_hstates - 1; i >= 0; i--) {
|
for (i = n_hstates - 1; i >= 0; i--) {
|
||||||
if (fee_incstate(channel, sidechanged, htlc_states[i]))
|
if (fee_incstate(channel, sidechanged, htlc_states[i]))
|
||||||
cflags |= (htlc_state_flags(htlc_states[i])
|
cflags |= (htlc_state_flags(htlc_states[i])
|
||||||
^ htlc_state_flags(htlc_states[i]+1));
|
^ htlc_state_flags(htlc_states[i]+1));
|
||||||
|
|
||||||
|
if (blockheight_incstate(channel, sidechanged, htlc_states[i]))
|
||||||
|
cflags |= (htlc_state_flags(htlc_states[i])
|
||||||
|
^ htlc_state_flags(htlc_states[i]+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return cflags;
|
return cflags;
|
||||||
@ -1154,6 +1190,16 @@ bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void channel_update_blockheight(struct channel *channel,
|
||||||
|
u32 blockheight)
|
||||||
|
{
|
||||||
|
status_debug("Setting %s blockheight to %u",
|
||||||
|
side_to_str(!channel->opener), blockheight);
|
||||||
|
|
||||||
|
start_height_update(channel->blockheight_states, channel->opener,
|
||||||
|
blockheight);
|
||||||
|
}
|
||||||
|
|
||||||
bool channel_sending_commit(struct channel *channel,
|
bool channel_sending_commit(struct channel *channel,
|
||||||
const struct htlc ***htlcs)
|
const struct htlc ***htlcs)
|
||||||
{
|
{
|
||||||
@ -1278,10 +1324,14 @@ bool pending_updates(const struct channel *channel,
|
|||||||
struct htlc_map_iter it;
|
struct htlc_map_iter it;
|
||||||
const struct htlc *htlc;
|
const struct htlc *htlc;
|
||||||
|
|
||||||
/* Initiator might have fee changes in play. */
|
/* Initiator might have fee changes or blockheight updates in play. */
|
||||||
if (side == channel->opener) {
|
if (side == channel->opener) {
|
||||||
if (!feerate_changes_done(channel->fee_states, uncommitted_ok))
|
if (!feerate_changes_done(channel->fee_states, uncommitted_ok))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!blockheight_changes_done(channel->blockheight_states,
|
||||||
|
uncommitted_ok))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (htlc = htlc_map_first(channel->htlcs, &it);
|
for (htlc = htlc_map_first(channel->htlcs, &it);
|
||||||
|
@ -17,6 +17,7 @@ struct existing_htlc;
|
|||||||
* @funding_txid: The commitment transaction id.
|
* @funding_txid: The commitment transaction id.
|
||||||
* @funding_txout: The commitment transaction output number.
|
* @funding_txout: The commitment transaction output number.
|
||||||
* @minimum_depth: The minimum confirmations needed for funding transaction.
|
* @minimum_depth: The minimum confirmations needed for funding transaction.
|
||||||
|
* @blockheight_states: The blockheight update states.
|
||||||
* @lease_expiry: The block the lease on this channel expires at; 0 if no lease.
|
* @lease_expiry: The block the lease on this channel expires at; 0 if no lease.
|
||||||
* @funding: The commitment transaction amount.
|
* @funding: The commitment transaction amount.
|
||||||
* @local_msat: The amount for the local side (remainder goes to remote)
|
* @local_msat: The amount for the local side (remainder goes to remote)
|
||||||
@ -38,6 +39,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
|||||||
const struct bitcoin_txid *funding_txid,
|
const struct bitcoin_txid *funding_txid,
|
||||||
unsigned int funding_txout,
|
unsigned int funding_txout,
|
||||||
u32 minimum_depth,
|
u32 minimum_depth,
|
||||||
|
const struct height_states *blockheight_states,
|
||||||
u32 lease_expiry,
|
u32 lease_expiry,
|
||||||
struct amount_sat funding,
|
struct amount_sat funding,
|
||||||
struct amount_msat local_msat,
|
struct amount_msat local_msat,
|
||||||
@ -184,6 +186,13 @@ bool can_opener_afford_feerate(const struct channel *channel, u32 feerate);
|
|||||||
*/
|
*/
|
||||||
bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw);
|
bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* channel_update_blockheight: Change blockheight on non-opener side.
|
||||||
|
* @channel: The channel
|
||||||
|
* @blockheight: current blockheight
|
||||||
|
*/
|
||||||
|
void channel_update_blockheight(struct channel *channel, u32 blockheight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* channel_feerate: Get fee rate for this side of channel.
|
* channel_feerate: Get fee rate for this side of channel.
|
||||||
* @channel: The channel
|
* @channel: The channel
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "../../common/blockheight_states.c"
|
||||||
#include "../../common/channel_id.c"
|
#include "../../common/channel_id.c"
|
||||||
#include "../../common/fee_states.c"
|
#include "../../common/fee_states.c"
|
||||||
#include "../../common/initial_channel.c"
|
#include "../../common/initial_channel.c"
|
||||||
@ -370,6 +371,7 @@ int main(int argc, const char *argv[])
|
|||||||
const struct htlc **htlc_map, **htlcs;
|
const struct htlc **htlc_map, **htlcs;
|
||||||
const u8 *funding_wscript, *funding_wscript_alt;
|
const u8 *funding_wscript, *funding_wscript_alt;
|
||||||
bool option_anchor_outputs = false;
|
bool option_anchor_outputs = false;
|
||||||
|
u32 blockheight = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
chainparams = chainparams_for_network("bitcoin");
|
chainparams = chainparams_for_network("bitcoin");
|
||||||
@ -481,6 +483,7 @@ int main(int argc, const char *argv[])
|
|||||||
derive_channel_id(&cid, &funding_txid, funding_output_index);
|
derive_channel_id(&cid, &funding_txid, funding_output_index);
|
||||||
lchannel = new_full_channel(tmpctx, &cid,
|
lchannel = new_full_channel(tmpctx, &cid,
|
||||||
&funding_txid, funding_output_index, 0,
|
&funding_txid, funding_output_index, 0,
|
||||||
|
take(new_height_states(NULL, LOCAL, &blockheight)),
|
||||||
0, /* No channel lease */
|
0, /* No channel lease */
|
||||||
funding_amount, to_local,
|
funding_amount, to_local,
|
||||||
take(new_fee_states(NULL, LOCAL,
|
take(new_fee_states(NULL, LOCAL,
|
||||||
@ -493,6 +496,7 @@ int main(int argc, const char *argv[])
|
|||||||
false, false, LOCAL);
|
false, false, LOCAL);
|
||||||
rchannel = new_full_channel(tmpctx, &cid,
|
rchannel = new_full_channel(tmpctx, &cid,
|
||||||
&funding_txid, funding_output_index, 0,
|
&funding_txid, funding_output_index, 0,
|
||||||
|
take(new_height_states(NULL, REMOTE, &blockheight)),
|
||||||
0, /* No channel lease */
|
0, /* No channel lease */
|
||||||
funding_amount, to_remote,
|
funding_amount, to_remote,
|
||||||
take(new_fee_states(NULL, REMOTE,
|
take(new_fee_states(NULL, REMOTE,
|
||||||
|
2
closingd/closingd_wiregen.c
generated
2
closingd/closingd_wiregen.c
generated
@ -195,4 +195,4 @@ bool fromwire_closingd_complete(const void *p)
|
|||||||
return false;
|
return false;
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:a8b0af1ae87e71bc448585060b8d449c3e5f0d0f4f3ac195dcd4d84f8176ae17
|
// SHA256STAMP:681e83ed1e1950220b1e9dbf168e5583e23120981b9a084eab5bc6ce1bc9a1aa
|
||||||
|
2
closingd/closingd_wiregen.h
generated
2
closingd/closingd_wiregen.h
generated
@ -56,4 +56,4 @@ bool fromwire_closingd_complete(const void *p);
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_CLOSINGD_CLOSINGD_WIREGEN_H */
|
#endif /* LIGHTNING_CLOSINGD_CLOSINGD_WIREGEN_H */
|
||||||
// SHA256STAMP:a8b0af1ae87e71bc448585060b8d449c3e5f0d0f4f3ac195dcd4d84f8176ae17
|
// SHA256STAMP:681e83ed1e1950220b1e9dbf168e5583e23120981b9a084eab5bc6ce1bc9a1aa
|
||||||
|
164
common/blockheight_states.c
Normal file
164
common/blockheight_states.c
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
#include <ccan/array_size/array_size.h>
|
||||||
|
#include <ccan/cast/cast.h>
|
||||||
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
|
#include <common/fee_states.h>
|
||||||
|
#include <common/type_to_string.h>
|
||||||
|
#include <wire/wire.h>
|
||||||
|
|
||||||
|
struct height_states *new_height_states(const tal_t *ctx,
|
||||||
|
enum side opener,
|
||||||
|
const u32 *blockheight)
|
||||||
|
{
|
||||||
|
struct height_states *states = tal(ctx, struct height_states);
|
||||||
|
|
||||||
|
/* Set to NULL except terminal value */
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(states->height); i++)
|
||||||
|
states->height[i] = NULL;
|
||||||
|
|
||||||
|
if (blockheight)
|
||||||
|
/* We reuse fee states! */
|
||||||
|
states->height[last_fee_state(opener)]
|
||||||
|
= tal_dup(states, u32, blockheight);
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 get_blockheight(const struct height_states *height_states,
|
||||||
|
enum side opener,
|
||||||
|
enum side side)
|
||||||
|
{
|
||||||
|
/* The first non-NULL blockheight committed to this side is current */
|
||||||
|
/* We use the same states as update_fee */
|
||||||
|
for (enum htlc_state i = first_fee_state(opener);
|
||||||
|
i <= last_fee_state(opener);
|
||||||
|
i++) {
|
||||||
|
if (!height_states->height[i])
|
||||||
|
continue;
|
||||||
|
if (!(htlc_state_flags(i) & HTLC_FLAG(side, HTLC_F_COMMITTED)))
|
||||||
|
continue;
|
||||||
|
return *height_states->height[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Some blockheight should always be set! */
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_height_update(struct height_states *height_states,
|
||||||
|
enum side opener,
|
||||||
|
u32 blockheight)
|
||||||
|
{
|
||||||
|
/* Same as the feerate states */
|
||||||
|
enum htlc_state start = first_fee_state(opener);
|
||||||
|
|
||||||
|
/* BOLT #2:
|
||||||
|
* Unlike an HTLC, `update_fee` is never closed but simply replaced.
|
||||||
|
*/
|
||||||
|
if (height_states->height[start] == NULL)
|
||||||
|
height_states->height[start] = tal(height_states, u32);
|
||||||
|
*height_states->height[start] = blockheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Are blockheights all agreed by both sides? */
|
||||||
|
bool blockheight_changes_done(const struct height_states *height_states,
|
||||||
|
bool ignore_uncommitted)
|
||||||
|
{
|
||||||
|
size_t num_blockheights = 0;
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(height_states->height); i++) {
|
||||||
|
if (ignore_uncommitted
|
||||||
|
&& (i == RCVD_ADD_HTLC || i == SENT_ADD_HTLC))
|
||||||
|
continue;
|
||||||
|
num_blockheights += (height_states->height[i] != NULL);
|
||||||
|
}
|
||||||
|
return num_blockheights == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool inc_height_state(struct height_states *height_states,
|
||||||
|
enum htlc_state hstate)
|
||||||
|
{
|
||||||
|
/* These only advance through ADDING states. */
|
||||||
|
assert(htlc_state_flags(hstate) & HTLC_ADDING);
|
||||||
|
|
||||||
|
if (!height_states->height[hstate])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* FIXME: We can never clash, except at final state unless someone
|
||||||
|
* has violated protocol (eg, send two revoke_and_ack back-to-back) */
|
||||||
|
tal_free(height_states->height[hstate+1]);
|
||||||
|
height_states->height[hstate+1] = height_states->height[hstate];
|
||||||
|
height_states->height[hstate] = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct height_states *dup_height_states(const tal_t *ctx,
|
||||||
|
const struct height_states *states TAKES)
|
||||||
|
{
|
||||||
|
struct height_states *n;
|
||||||
|
|
||||||
|
if (taken(states))
|
||||||
|
return cast_const(struct height_states *,
|
||||||
|
tal_steal(ctx, states));
|
||||||
|
|
||||||
|
n = tal_dup(ctx, struct height_states, states);
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(n->height); i++) {
|
||||||
|
if (n->height[i])
|
||||||
|
n->height[i] = tal_dup(n, u32, n->height[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: we don't know opener inside fromwire_height_states, so can't do
|
||||||
|
* this there :( */
|
||||||
|
bool height_states_valid(const struct height_states *states, enum side opener)
|
||||||
|
{
|
||||||
|
/* We use the same states as update fee */
|
||||||
|
return states->height[last_fee_state(opener)] != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void towire_height_states(u8 **pptr, const struct height_states *states)
|
||||||
|
{
|
||||||
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(states->height); i++) {
|
||||||
|
/* We don't send uncommitted feestates */
|
||||||
|
if (!(htlc_state_flags(i) & (HTLC_REMOTE_F_COMMITTED
|
||||||
|
| HTLC_LOCAL_F_COMMITTED))
|
||||||
|
|| states->height[i] == NULL) {
|
||||||
|
towire_bool(pptr, false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
towire_bool(pptr, true);
|
||||||
|
towire_u32(pptr, *states->height[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct height_states *fromwire_height_states(const tal_t *ctx, const u8 **cursor, size_t *max)
|
||||||
|
{
|
||||||
|
struct height_states *states = tal(ctx, struct height_states);
|
||||||
|
|
||||||
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(states->height); i++) {
|
||||||
|
if (fromwire_bool(cursor, max)) {
|
||||||
|
states->height[i] = tal(states, u32);
|
||||||
|
*states->height[i] = fromwire_u32(cursor, max);
|
||||||
|
} else {
|
||||||
|
states->height[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!*cursor)
|
||||||
|
return tal_free(states);
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *fmt_height_states(const tal_t *ctx,
|
||||||
|
const struct height_states *states)
|
||||||
|
{
|
||||||
|
char *ret = tal_strdup(ctx, "{");
|
||||||
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(states->height); i++) {
|
||||||
|
if (states->height[i] != NULL)
|
||||||
|
tal_append_fmt(&ret, " %s:%u",
|
||||||
|
htlc_state_name(i),
|
||||||
|
*states->height[i]);
|
||||||
|
}
|
||||||
|
tal_append_fmt(&ret, " }");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
REGISTER_TYPE_TO_STRING(height_states, fmt_height_states);
|
79
common/blockheight_states.h
Normal file
79
common/blockheight_states.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#ifndef LIGHTNING_COMMON_BLOCKHEIGHT_STATES_H
|
||||||
|
#define LIGHTNING_COMMON_BLOCKHEIGHT_STATES_H
|
||||||
|
#include "config.h"
|
||||||
|
#include <ccan/tal/tal.h>
|
||||||
|
#include <common/htlc.h>
|
||||||
|
|
||||||
|
struct height_states {
|
||||||
|
/* Current blockheight: goes through same
|
||||||
|
* state machine as feestate addition.
|
||||||
|
*
|
||||||
|
* We need to know if there's an actual change pending though (even if
|
||||||
|
* it's a "change" to an idential feerate!) so we use pointers.
|
||||||
|
*/
|
||||||
|
u32 *height[HTLC_STATE_INVALID];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new_height_states: Initialize a height_states structure as at
|
||||||
|
* open-of-channel.
|
||||||
|
* @ctx: the tal ctx to allocate off
|
||||||
|
* @opener: which side opened the channel
|
||||||
|
* (and thus, proposes blockheight updates).
|
||||||
|
* @blockheight: the initial blockheight (if any).
|
||||||
|
*/
|
||||||
|
struct height_states *new_height_states(const tal_t *ctx,
|
||||||
|
enum side opener,
|
||||||
|
const u32 *blockheight);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_blockheight: Get the current blockheight
|
||||||
|
* @height_states: the blockheight state machine
|
||||||
|
* @opener: which side opened the channel
|
||||||
|
* (and thus, proposes blockheight updates).
|
||||||
|
* @side: which side to get the blockheight for
|
||||||
|
*/
|
||||||
|
u32 get_blockheight(const struct height_states *height_states,
|
||||||
|
enum side opener,
|
||||||
|
enum side side);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start_height_update: feed a new blockheight update into state machine.
|
||||||
|
* @height_states: the height state machine
|
||||||
|
* @opener: which side opened the channel (and thus, proposes
|
||||||
|
* blockheight updates).
|
||||||
|
* @blockheight: the new blockheight.
|
||||||
|
*/
|
||||||
|
void start_height_update(struct height_states *height_states,
|
||||||
|
enum side opener,
|
||||||
|
u32 blockheight);
|
||||||
|
/**
|
||||||
|
* inc_height_state: move this blockheight to the next state.
|
||||||
|
* @height_states: the blockheight state machine
|
||||||
|
* @hstate: state
|
||||||
|
*
|
||||||
|
* Moves height_states[hstate] to height_states[hstate+1], if not NULL.
|
||||||
|
* Returns true if it wasn't NULL.
|
||||||
|
*/
|
||||||
|
bool inc_height_state(struct height_states *height_states,
|
||||||
|
enum htlc_state hstate);
|
||||||
|
|
||||||
|
/* Are blockheights all agreed by both sides? */
|
||||||
|
bool blockheight_changes_done(const struct height_states *height_states,
|
||||||
|
bool ignore_uncommitted);
|
||||||
|
|
||||||
|
/* Duplicate a set of height states */
|
||||||
|
struct height_states *dup_height_states(const tal_t *ctx,
|
||||||
|
const struct height_states *states TAKES);
|
||||||
|
|
||||||
|
/* Marshal and unmarshal */
|
||||||
|
void towire_height_states(u8 **pptr, const struct height_states *height_states);
|
||||||
|
/* FIXME: You must check that height_states_valid! */
|
||||||
|
struct height_states *fromwire_height_states(const tal_t *ctx,
|
||||||
|
const u8 **cursor, size_t *max);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is this height_state struct valid for this side?
|
||||||
|
*/
|
||||||
|
bool height_states_valid(const struct height_states *states, enum side opener);
|
||||||
|
#endif /* LIGHTNING_COMMON_BLOCKHEIGHT_STATES_H */
|
@ -6,6 +6,7 @@
|
|||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/cast/cast.h>
|
#include <ccan/cast/cast.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
#include <common/initial_channel.h>
|
#include <common/initial_channel.h>
|
||||||
@ -21,6 +22,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
|||||||
const struct bitcoin_txid *funding_txid,
|
const struct bitcoin_txid *funding_txid,
|
||||||
unsigned int funding_txout,
|
unsigned int funding_txout,
|
||||||
u32 minimum_depth,
|
u32 minimum_depth,
|
||||||
|
const struct height_states *height_states TAKES,
|
||||||
u32 lease_expiry,
|
u32 lease_expiry,
|
||||||
struct amount_sat funding,
|
struct amount_sat funding,
|
||||||
struct amount_msat local_msatoshi,
|
struct amount_msat local_msatoshi,
|
||||||
@ -58,6 +60,13 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
|||||||
/* takes() if necessary */
|
/* takes() if necessary */
|
||||||
channel->fee_states = dup_fee_states(channel, fee_states);
|
channel->fee_states = dup_fee_states(channel, fee_states);
|
||||||
|
|
||||||
|
/* takes() if necessary */
|
||||||
|
if (!height_states)
|
||||||
|
channel->blockheight_states = NULL;
|
||||||
|
else
|
||||||
|
channel->blockheight_states
|
||||||
|
= dup_height_states(channel, height_states);
|
||||||
|
|
||||||
channel->view[LOCAL].owed[LOCAL]
|
channel->view[LOCAL].owed[LOCAL]
|
||||||
= channel->view[REMOTE].owed[LOCAL]
|
= channel->view[REMOTE].owed[LOCAL]
|
||||||
= local_msatoshi;
|
= local_msatoshi;
|
||||||
@ -108,8 +117,11 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
|||||||
if (channel->lease_expiry == 0)
|
if (channel->lease_expiry == 0)
|
||||||
csv_lock = 1;
|
csv_lock = 1;
|
||||||
else
|
else
|
||||||
/* FIXME: */
|
/* For the initial commitment, starts max lease */
|
||||||
csv_lock = 1;
|
csv_lock = channel->lease_expiry
|
||||||
|
- get_blockheight(channel->blockheight_states,
|
||||||
|
channel->opener,
|
||||||
|
side);
|
||||||
|
|
||||||
*wscript = bitcoin_redeem_2of2(ctx,
|
*wscript = bitcoin_redeem_2of2(ctx,
|
||||||
&channel->funding_pubkey[side],
|
&channel->funding_pubkey[side],
|
||||||
|
@ -62,6 +62,10 @@ struct channel {
|
|||||||
/* Fee changes, some which may be in transit */
|
/* Fee changes, some which may be in transit */
|
||||||
struct fee_states *fee_states;
|
struct fee_states *fee_states;
|
||||||
|
|
||||||
|
/* Blockheight changes, some which may be in transit
|
||||||
|
* (option_will_fund)*/
|
||||||
|
struct height_states *blockheight_states;
|
||||||
|
|
||||||
/* What it looks like to each side. */
|
/* What it looks like to each side. */
|
||||||
struct channel_view view[NUM_SIDES];
|
struct channel_view view[NUM_SIDES];
|
||||||
|
|
||||||
@ -82,7 +86,8 @@ struct channel {
|
|||||||
* @funding_txid: The commitment transaction id.
|
* @funding_txid: The commitment transaction id.
|
||||||
* @funding_txout: The commitment transaction output number.
|
* @funding_txout: The commitment transaction output number.
|
||||||
* @minimum_depth: The minimum confirmations needed for funding transaction.
|
* @minimum_depth: The minimum confirmations needed for funding transaction.
|
||||||
* @lease_expiry: Block the lease expires
|
* @height_states: The blockheight update states.
|
||||||
|
* @lease_expiry: Block the lease expires.
|
||||||
* @funding_satoshis: The commitment transaction amount.
|
* @funding_satoshis: The commitment transaction amount.
|
||||||
* @local_msatoshi: The amount for the local side (remainder goes to remote)
|
* @local_msatoshi: The amount for the local side (remainder goes to remote)
|
||||||
* @fee_states: The fee update states.
|
* @fee_states: The fee update states.
|
||||||
@ -103,6 +108,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
|||||||
const struct bitcoin_txid *funding_txid,
|
const struct bitcoin_txid *funding_txid,
|
||||||
unsigned int funding_txout,
|
unsigned int funding_txout,
|
||||||
u32 minimum_depth,
|
u32 minimum_depth,
|
||||||
|
const struct height_states *height_states TAKES,
|
||||||
u32 lease_expiry,
|
u32 lease_expiry,
|
||||||
struct amount_sat funding,
|
struct amount_sat funding,
|
||||||
struct amount_msat local_msatoshi,
|
struct amount_msat local_msatoshi,
|
||||||
|
2
common/peer_status_wiregen.c
generated
2
common/peer_status_wiregen.c
generated
@ -80,4 +80,4 @@ bool fromwire_status_peer_error(const tal_t *ctx, const void *p, struct channel_
|
|||||||
fromwire_u8_array(&cursor, &plen, *error_for_them, len);
|
fromwire_u8_array(&cursor, &plen, *error_for_them, len);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:9eae5e1735b52e459db2548ff73399a8cb503ddbf72defc5bfa4022f3682ffd5
|
// SHA256STAMP:db80a04b587e0918ef55f7e82519f7ff86620c5ec4fd845452214059c1cdbd41
|
||||||
|
2
common/peer_status_wiregen.h
generated
2
common/peer_status_wiregen.h
generated
@ -34,4 +34,4 @@ bool fromwire_status_peer_error(const tal_t *ctx, const void *p, struct channel_
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_COMMON_PEER_STATUS_WIREGEN_H */
|
#endif /* LIGHTNING_COMMON_PEER_STATUS_WIREGEN_H */
|
||||||
// SHA256STAMP:9eae5e1735b52e459db2548ff73399a8cb503ddbf72defc5bfa4022f3682ffd5
|
// SHA256STAMP:db80a04b587e0918ef55f7e82519f7ff86620c5ec4fd845452214059c1cdbd41
|
||||||
|
2
common/status_wiregen.c
generated
2
common/status_wiregen.c
generated
@ -214,4 +214,4 @@ bool fromwire_status_version(const tal_t *ctx, const void *p, wirestring **versi
|
|||||||
*version = fromwire_wirestring(ctx, &cursor, &plen);
|
*version = fromwire_wirestring(ctx, &cursor, &plen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:676725f967cd09851ed0d872ed58ed058fa9de7d95acca7169e0262e7d0b2c64
|
// SHA256STAMP:6f868de7019bd204be0d90618a044c20ec1170430e3196674040ddb7f7278e80
|
||||||
|
2
common/status_wiregen.h
generated
2
common/status_wiregen.h
generated
@ -58,4 +58,4 @@ bool fromwire_status_version(const tal_t *ctx, const void *p, wirestring **versi
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_COMMON_STATUS_WIREGEN_H */
|
#endif /* LIGHTNING_COMMON_STATUS_WIREGEN_H */
|
||||||
// SHA256STAMP:676725f967cd09851ed0d872ed58ed058fa9de7d95acca7169e0262e7d0b2c64
|
// SHA256STAMP:6f868de7019bd204be0d90618a044c20ec1170430e3196674040ddb7f7278e80
|
||||||
|
@ -37,6 +37,7 @@ union printable_types {
|
|||||||
const struct amount_msat *amount_msat;
|
const struct amount_msat *amount_msat;
|
||||||
const struct amount_sat *amount_sat;
|
const struct amount_sat *amount_sat;
|
||||||
const struct fee_states *fee_states;
|
const struct fee_states *fee_states;
|
||||||
|
const struct height_states *height_states;
|
||||||
const char *charp_;
|
const char *charp_;
|
||||||
const struct wally_psbt *wally_psbt;
|
const struct wally_psbt *wally_psbt;
|
||||||
const struct wally_tx *wally_tx;
|
const struct wally_tx *wally_tx;
|
||||||
|
2
connectd/connectd_gossipd_wiregen.c
generated
2
connectd/connectd_gossipd_wiregen.c
generated
@ -161,4 +161,4 @@ bool fromwire_gossipd_get_addrs_reply(const tal_t *ctx, const void *p, struct wi
|
|||||||
fromwire_wireaddr(&cursor, &plen, *addrs + i);
|
fromwire_wireaddr(&cursor, &plen, *addrs + i);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:5565fac68fbf90e24ef5f8230483b52952d342080d44ce9fb8ae0e9843ad1529
|
// SHA256STAMP:a115dcd604f1bcbe48bf57b25bfc2b59ec7eff3c4790812fa1c460aee2b50811
|
||||||
|
2
connectd/connectd_gossipd_wiregen.h
generated
2
connectd/connectd_gossipd_wiregen.h
generated
@ -54,4 +54,4 @@ bool fromwire_gossipd_get_addrs_reply(const tal_t *ctx, const void *p, struct wi
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_CONNECTD_CONNECTD_GOSSIPD_WIREGEN_H */
|
#endif /* LIGHTNING_CONNECTD_CONNECTD_GOSSIPD_WIREGEN_H */
|
||||||
// SHA256STAMP:5565fac68fbf90e24ef5f8230483b52952d342080d44ce9fb8ae0e9843ad1529
|
// SHA256STAMP:a115dcd604f1bcbe48bf57b25bfc2b59ec7eff3c4790812fa1c460aee2b50811
|
||||||
|
2
connectd/connectd_wiregen.c
generated
2
connectd/connectd_wiregen.c
generated
@ -443,4 +443,4 @@ bool fromwire_connectd_dev_memleak_reply(const void *p, bool *leak)
|
|||||||
*leak = fromwire_bool(&cursor, &plen);
|
*leak = fromwire_bool(&cursor, &plen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:533fec0547d283247c2fbd2ef52c7df86614f5152c8f3282e0e1e699de3af5d4
|
// SHA256STAMP:27a03f6c7a77a83be6fc4d063fd37d4bc47e7280310f19d72859ff3f409e05ca
|
||||||
|
2
connectd/connectd_wiregen.h
generated
2
connectd/connectd_wiregen.h
generated
@ -110,4 +110,4 @@ bool fromwire_connectd_dev_memleak_reply(const void *p, bool *leak);
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_CONNECTD_CONNECTD_WIREGEN_H */
|
#endif /* LIGHTNING_CONNECTD_CONNECTD_WIREGEN_H */
|
||||||
// SHA256STAMP:533fec0547d283247c2fbd2ef52c7df86614f5152c8f3282e0e1e699de3af5d4
|
// SHA256STAMP:27a03f6c7a77a83be6fc4d063fd37d4bc47e7280310f19d72859ff3f409e05ca
|
||||||
|
@ -18,6 +18,7 @@ DEVTOOLS_COMMON_OBJS := \
|
|||||||
common/bech32_util.o \
|
common/bech32_util.o \
|
||||||
common/bigsize.o \
|
common/bigsize.o \
|
||||||
common/bolt11.o \
|
common/bolt11.o \
|
||||||
|
common/blockheight_states.o \
|
||||||
common/channel_id.o \
|
common/channel_id.o \
|
||||||
common/crypto_state.o \
|
common/crypto_state.o \
|
||||||
common/decode_array.o \
|
common/decode_array.o \
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <channeld/full_channel.h>
|
#include <channeld/full_channel.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/channel_id.h>
|
#include <common/channel_id.h>
|
||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
@ -271,6 +272,7 @@ int main(int argc, char *argv[])
|
|||||||
struct pubkey local_htlc_pubkey, remote_htlc_pubkey;
|
struct pubkey local_htlc_pubkey, remote_htlc_pubkey;
|
||||||
bool option_static_remotekey = false, option_anchor_outputs = false;
|
bool option_static_remotekey = false, option_anchor_outputs = false;
|
||||||
struct sha256_double hash;
|
struct sha256_double hash;
|
||||||
|
u32 blockheight = 0;
|
||||||
|
|
||||||
setup_locale();
|
setup_locale();
|
||||||
chainparams = chainparams_for_network("bitcoin");
|
chainparams = chainparams_for_network("bitcoin");
|
||||||
@ -394,6 +396,8 @@ int main(int argc, char *argv[])
|
|||||||
channel = new_full_channel(NULL,
|
channel = new_full_channel(NULL,
|
||||||
&cid,
|
&cid,
|
||||||
&funding_txid, funding_outnum, 1,
|
&funding_txid, funding_outnum, 1,
|
||||||
|
take(new_height_states(NULL, fee_payer,
|
||||||
|
&blockheight)),
|
||||||
0, /* Defaults to no lease */
|
0, /* Defaults to no lease */
|
||||||
funding_amount,
|
funding_amount,
|
||||||
local_msat,
|
local_msat,
|
||||||
|
2
gossipd/gossip_store_wiregen.c
generated
2
gossipd/gossip_store_wiregen.c
generated
@ -210,4 +210,4 @@ bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx, const void *p, str
|
|||||||
fromwire_u8_array(&cursor, &plen, *features, flen);
|
fromwire_u8_array(&cursor, &plen, *features, flen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:f5b4fcddb25b45895865636a90b9a5e0f9d2acfba04f4e9ecc14d2dfcad1e01a
|
// SHA256STAMP:a709d2e8f179fb393064e210e72f1118fd60f67134d5f94fe33dc58a62f38ff7
|
||||||
|
2
gossipd/gossip_store_wiregen.h
generated
2
gossipd/gossip_store_wiregen.h
generated
@ -63,4 +63,4 @@ bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx, const void *p, str
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_WIREGEN_H */
|
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_WIREGEN_H */
|
||||||
// SHA256STAMP:f5b4fcddb25b45895865636a90b9a5e0f9d2acfba04f4e9ecc14d2dfcad1e01a
|
// SHA256STAMP:a709d2e8f179fb393064e210e72f1118fd60f67134d5f94fe33dc58a62f38ff7
|
||||||
|
2
gossipd/gossipd_peerd_wiregen.c
generated
2
gossipd/gossipd_peerd_wiregen.c
generated
@ -161,4 +161,4 @@ bool fromwire_gossipd_local_channel_announcement(const tal_t *ctx, const void *p
|
|||||||
fromwire_u8_array(&cursor, &plen, *cannount, len);
|
fromwire_u8_array(&cursor, &plen, *cannount, len);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:bf705b59df34f8e21f337759dfd6d56e610be91c1838a1eef25c807d5b2e7184
|
// SHA256STAMP:3b60c444839f3c615c80609a295f43fd95f1bd6e9b4a66e56c95cf0e4e7607b1
|
||||||
|
2
gossipd/gossipd_peerd_wiregen.h
generated
2
gossipd/gossipd_peerd_wiregen.h
generated
@ -57,4 +57,4 @@ bool fromwire_gossipd_local_channel_announcement(const tal_t *ctx, const void *p
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_PEERD_WIREGEN_H */
|
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_PEERD_WIREGEN_H */
|
||||||
// SHA256STAMP:bf705b59df34f8e21f337759dfd6d56e610be91c1838a1eef25c807d5b2e7184
|
// SHA256STAMP:3b60c444839f3c615c80609a295f43fd95f1bd6e9b4a66e56c95cf0e4e7607b1
|
||||||
|
2
gossipd/gossipd_wiregen.c
generated
2
gossipd/gossipd_wiregen.c
generated
@ -777,4 +777,4 @@ bool fromwire_gossipd_new_lease_rates(const void *p, struct lease_rates *rates)
|
|||||||
fromwire_lease_rates(&cursor, &plen, rates);
|
fromwire_lease_rates(&cursor, &plen, rates);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:c511c2859bffa718708c4cceedd59807d0a43cd48060a59bf7cbabfa2f6515f9
|
// SHA256STAMP:a0408d2e1f668c085378bc2729e08d8712a95edc48d12df8c6cbf063aeddbf32
|
||||||
|
2
gossipd/gossipd_wiregen.h
generated
2
gossipd/gossipd_wiregen.h
generated
@ -188,4 +188,4 @@ bool fromwire_gossipd_new_lease_rates(const void *p, struct lease_rates *rates);
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_WIREGEN_H */
|
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_WIREGEN_H */
|
||||||
// SHA256STAMP:c511c2859bffa718708c4cceedd59807d0a43cd48060a59bf7cbabfa2f6515f9
|
// SHA256STAMP:a0408d2e1f668c085378bc2729e08d8712a95edc48d12df8c6cbf063aeddbf32
|
||||||
|
2
hsmd/hsmd_wiregen.c
generated
2
hsmd/hsmd_wiregen.c
generated
@ -1331,4 +1331,4 @@ bool fromwire_hsmd_sign_option_will_fund_offer_reply(const void *p, secp256k1_ec
|
|||||||
fromwire_secp256k1_ecdsa_signature(&cursor, &plen, rsig);
|
fromwire_secp256k1_ecdsa_signature(&cursor, &plen, rsig);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:c1ec339d1925da25ee587ffb4fb5e35d0b3c578e525f519384c8fecc1054dc2a
|
// SHA256STAMP:5cc29ba49eb086d023342733bcaeb16b5b8e3c5b7b9d5826e70dd4f46b0d1dd2
|
||||||
|
2
hsmd/hsmd_wiregen.h
generated
2
hsmd/hsmd_wiregen.h
generated
@ -295,4 +295,4 @@ bool fromwire_hsmd_sign_option_will_fund_offer_reply(const void *p, secp256k1_ec
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_HSMD_HSMD_WIREGEN_H */
|
#endif /* LIGHTNING_HSMD_HSMD_WIREGEN_H */
|
||||||
// SHA256STAMP:c1ec339d1925da25ee587ffb4fb5e35d0b3c578e525f519384c8fecc1054dc2a
|
// SHA256STAMP:5cc29ba49eb086d023342733bcaeb16b5b8e3c5b7b9d5826e70dd4f46b0d1dd2
|
||||||
|
@ -69,6 +69,7 @@ LIGHTNINGD_COMMON_OBJS := \
|
|||||||
common/bigsize.o \
|
common/bigsize.o \
|
||||||
common/bip32.o \
|
common/bip32.o \
|
||||||
common/blinding.o \
|
common/blinding.o \
|
||||||
|
common/blockheight_states.o \
|
||||||
common/bolt11.o \
|
common/bolt11.o \
|
||||||
common/bolt11_json.o \
|
common/bolt11_json.o \
|
||||||
common/bolt12.o \
|
common/bolt12.o \
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
|
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/closing_fee.h>
|
#include <common/closing_fee.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
@ -163,8 +164,8 @@ new_inflight(struct channel *channel,
|
|||||||
const struct bitcoin_signature last_sig,
|
const struct bitcoin_signature last_sig,
|
||||||
const u32 lease_expiry,
|
const u32 lease_expiry,
|
||||||
const secp256k1_ecdsa_signature *lease_commit_sig,
|
const secp256k1_ecdsa_signature *lease_commit_sig,
|
||||||
const u32 lease_chan_max_msat,
|
const u32 lease_chan_max_msat, const u16 lease_chan_max_ppt,
|
||||||
const u16 lease_chan_max_ppt)
|
const u32 lease_blockheight_start)
|
||||||
{
|
{
|
||||||
struct wally_psbt *last_tx_psbt_clone;
|
struct wally_psbt *last_tx_psbt_clone;
|
||||||
struct channel_inflight *inflight
|
struct channel_inflight *inflight
|
||||||
@ -189,8 +190,16 @@ new_inflight(struct channel *channel,
|
|||||||
inflight->last_sig = last_sig;
|
inflight->last_sig = last_sig;
|
||||||
inflight->tx_broadcast = false;
|
inflight->tx_broadcast = false;
|
||||||
|
|
||||||
|
/* Channel lease infos */
|
||||||
|
inflight->lease_blockheight_start = lease_blockheight_start;
|
||||||
inflight->lease_expiry = lease_expiry;
|
inflight->lease_expiry = lease_expiry;
|
||||||
inflight->lease_commit_sig = tal_dup(inflight, secp256k1_ecdsa_signature, lease_commit_sig);
|
if (lease_commit_sig)
|
||||||
|
inflight->lease_commit_sig
|
||||||
|
= tal_dup(inflight, secp256k1_ecdsa_signature,
|
||||||
|
lease_commit_sig);
|
||||||
|
else
|
||||||
|
inflight->lease_commit_sig = NULL;
|
||||||
|
|
||||||
inflight->lease_chan_max_msat = lease_chan_max_msat;
|
inflight->lease_chan_max_msat = lease_chan_max_msat;
|
||||||
inflight->lease_chan_max_ppt = lease_chan_max_ppt;
|
inflight->lease_chan_max_ppt = lease_chan_max_ppt;
|
||||||
|
|
||||||
@ -353,6 +362,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||||||
enum state_change reason,
|
enum state_change reason,
|
||||||
/* NULL or stolen */
|
/* NULL or stolen */
|
||||||
const struct bitcoin_outpoint *shutdown_wrong_funding,
|
const struct bitcoin_outpoint *shutdown_wrong_funding,
|
||||||
|
const struct height_states *height_states TAKES,
|
||||||
u32 lease_expiry,
|
u32 lease_expiry,
|
||||||
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
||||||
u32 lease_chan_max_msat,
|
u32 lease_chan_max_msat,
|
||||||
@ -449,6 +459,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||||||
channel->lease_commit_sig = tal_steal(channel, lease_commit_sig);
|
channel->lease_commit_sig = tal_steal(channel, lease_commit_sig);
|
||||||
channel->lease_chan_max_msat = lease_chan_max_msat;
|
channel->lease_chan_max_msat = lease_chan_max_msat;
|
||||||
channel->lease_chan_max_ppt = lease_chan_max_ppt;
|
channel->lease_chan_max_ppt = lease_chan_max_ppt;
|
||||||
|
channel->blockheight_states = dup_height_states(channel, height_states);
|
||||||
|
|
||||||
list_add_tail(&peer->channels, &channel->list);
|
list_add_tail(&peer->channels, &channel->list);
|
||||||
channel->rr_number = peer->ld->rr_counter++;
|
channel->rr_number = peer->ld->rr_counter++;
|
||||||
|
@ -51,6 +51,7 @@ struct channel_inflight {
|
|||||||
secp256k1_ecdsa_signature *lease_commit_sig;
|
secp256k1_ecdsa_signature *lease_commit_sig;
|
||||||
u32 lease_chan_max_msat;
|
u32 lease_chan_max_msat;
|
||||||
u16 lease_chan_max_ppt;
|
u16 lease_chan_max_ppt;
|
||||||
|
u32 lease_blockheight_start;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct open_attempt {
|
struct open_attempt {
|
||||||
@ -150,6 +151,9 @@ struct channel {
|
|||||||
/* Fee status */
|
/* Fee status */
|
||||||
const struct fee_states *fee_states;
|
const struct fee_states *fee_states;
|
||||||
|
|
||||||
|
/* Height states (option_will_fund, update_blockheight) */
|
||||||
|
const struct height_states *blockheight_states;
|
||||||
|
|
||||||
/* Our local basepoints */
|
/* Our local basepoints */
|
||||||
struct basepoints local_basepoints;
|
struct basepoints local_basepoints;
|
||||||
|
|
||||||
@ -292,6 +296,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||||||
enum state_change reason,
|
enum state_change reason,
|
||||||
/* NULL or stolen */
|
/* NULL or stolen */
|
||||||
const struct bitcoin_outpoint *shutdown_wrong_funding STEALS,
|
const struct bitcoin_outpoint *shutdown_wrong_funding STEALS,
|
||||||
|
const struct height_states *height_states TAKES,
|
||||||
u32 lease_expiry,
|
u32 lease_expiry,
|
||||||
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
||||||
u32 lease_chan_max_msat,
|
u32 lease_chan_max_msat,
|
||||||
@ -311,7 +316,8 @@ new_inflight(struct channel *channel,
|
|||||||
const u32 lease_expiry,
|
const u32 lease_expiry,
|
||||||
const secp256k1_ecdsa_signature *lease_commit_sig,
|
const secp256k1_ecdsa_signature *lease_commit_sig,
|
||||||
const u32 lease_chan_max_msat,
|
const u32 lease_chan_max_msat,
|
||||||
const u16 lease_chan_max_ppt);
|
const u16 lease_chan_max_ppt,
|
||||||
|
const u32 lease_blockheight_start);
|
||||||
|
|
||||||
/* Given a txid, find an inflight channel stub. Returns NULL if none found */
|
/* Given a txid, find an inflight channel stub. Returns NULL if none found */
|
||||||
struct channel_inflight *channel_inflight_find(struct channel *channel,
|
struct channel_inflight *channel_inflight_find(struct channel *channel,
|
||||||
|
@ -69,6 +69,30 @@ static void try_update_feerates(struct lightningd *ld, struct channel *channel)
|
|||||||
update_feerates(ld, channel);
|
update_feerates(ld, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void try_update_blockheight(struct lightningd *ld,
|
||||||
|
struct channel *channel,
|
||||||
|
u32 blockheight)
|
||||||
|
{
|
||||||
|
u8 *msg;
|
||||||
|
|
||||||
|
/* We use the same heuristic for channel states as feerates */
|
||||||
|
if (!channel_fees_can_change(channel))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Can't if no daemon listening. */
|
||||||
|
if (!channel->owner)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* We don't update the blockheight for non-leased chans */
|
||||||
|
if (channel->lease_expiry == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
log_debug(ld->log, "update_blockheight: height = %u", blockheight);
|
||||||
|
|
||||||
|
msg = towire_channeld_blockheight(NULL, blockheight);
|
||||||
|
subd_send_msg(channel->owner, take(msg));
|
||||||
|
}
|
||||||
|
|
||||||
void notify_feerate_change(struct lightningd *ld)
|
void notify_feerate_change(struct lightningd *ld)
|
||||||
{
|
{
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
@ -155,6 +179,9 @@ static void lockin_complete(struct channel *channel)
|
|||||||
/* Fees might have changed (and we use IMMEDIATE once we're funded),
|
/* Fees might have changed (and we use IMMEDIATE once we're funded),
|
||||||
* so update now. */
|
* so update now. */
|
||||||
try_update_feerates(channel->peer->ld, channel);
|
try_update_feerates(channel->peer->ld, channel);
|
||||||
|
|
||||||
|
try_update_blockheight(channel->peer->ld, channel,
|
||||||
|
get_block_height(channel->peer->ld->topology));
|
||||||
channel_record_open(channel);
|
channel_record_open(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,6 +478,7 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
|||||||
case WIRE_CHANNELD_SEND_SHUTDOWN:
|
case WIRE_CHANNELD_SEND_SHUTDOWN:
|
||||||
case WIRE_CHANNELD_DEV_REENABLE_COMMIT:
|
case WIRE_CHANNELD_DEV_REENABLE_COMMIT:
|
||||||
case WIRE_CHANNELD_FEERATES:
|
case WIRE_CHANNELD_FEERATES:
|
||||||
|
case WIRE_CHANNELD_BLOCKHEIGHT:
|
||||||
case WIRE_CHANNELD_SPECIFIC_FEERATES:
|
case WIRE_CHANNELD_SPECIFIC_FEERATES:
|
||||||
case WIRE_CHANNELD_DEV_MEMLEAK:
|
case WIRE_CHANNELD_DEV_MEMLEAK:
|
||||||
case WIRE_CHANNELD_DEV_QUIESCE:
|
case WIRE_CHANNELD_DEV_QUIESCE:
|
||||||
@ -587,6 +615,9 @@ void peer_start_channeld(struct channel *channel,
|
|||||||
channel->funding_outnum,
|
channel->funding_outnum,
|
||||||
channel->funding,
|
channel->funding,
|
||||||
channel->minimum_depth,
|
channel->minimum_depth,
|
||||||
|
get_block_height(ld->topology),
|
||||||
|
channel->blockheight_states,
|
||||||
|
channel->lease_expiry,
|
||||||
&channel->our_config,
|
&channel->our_config,
|
||||||
&channel->channel_info.their_config,
|
&channel->channel_info.their_config,
|
||||||
channel->fee_states,
|
channel->fee_states,
|
||||||
@ -647,9 +678,13 @@ void peer_start_channeld(struct channel *channel,
|
|||||||
/* We don't expect a response: we are triggered by funding_depth_cb. */
|
/* We don't expect a response: we are triggered by funding_depth_cb. */
|
||||||
subd_send_msg(channel->owner, take(initmsg));
|
subd_send_msg(channel->owner, take(initmsg));
|
||||||
|
|
||||||
/* On restart, feerate might not be what we expect: adjust now. */
|
/* On restart, feerate and blockheight
|
||||||
if (channel->opener == LOCAL)
|
* might not be what we expect: adjust now. */
|
||||||
|
if (channel->opener == LOCAL) {
|
||||||
try_update_feerates(ld, channel);
|
try_update_feerates(ld, channel);
|
||||||
|
try_update_blockheight(ld, channel,
|
||||||
|
get_block_height(ld->topology));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool channel_tell_depth(struct lightningd *ld,
|
bool channel_tell_depth(struct lightningd *ld,
|
||||||
@ -757,7 +792,11 @@ void channel_notify_new_block(struct lightningd *ld,
|
|||||||
continue;
|
continue;
|
||||||
if (is_fundee_should_forget(ld, channel, block_height)) {
|
if (is_fundee_should_forget(ld, channel, block_height)) {
|
||||||
tal_arr_expand(&to_forget, channel);
|
tal_arr_expand(&to_forget, channel);
|
||||||
}
|
} else
|
||||||
|
/* Let channels know about new blocks,
|
||||||
|
* required for lease updates */
|
||||||
|
try_update_blockheight(ld, channel,
|
||||||
|
block_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <ccan/ccan/tal/tal.h>
|
#include <ccan/ccan/tal/tal.h>
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/channel_id.h>
|
#include <common/channel_id.h>
|
||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
@ -1116,7 +1117,8 @@ wallet_update_channel(struct lightningd *ld,
|
|||||||
const u32 lease_expiry,
|
const u32 lease_expiry,
|
||||||
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
||||||
const u32 lease_chan_max_msat,
|
const u32 lease_chan_max_msat,
|
||||||
const u16 lease_chan_max_ppt)
|
const u16 lease_chan_max_ppt,
|
||||||
|
const u32 lease_blockheight_start)
|
||||||
{
|
{
|
||||||
struct amount_msat our_msat;
|
struct amount_msat our_msat;
|
||||||
struct channel_inflight *inflight;
|
struct channel_inflight *inflight;
|
||||||
@ -1143,6 +1145,11 @@ wallet_update_channel(struct lightningd *ld,
|
|||||||
channel->lease_chan_max_msat = lease_chan_max_msat;
|
channel->lease_chan_max_msat = lease_chan_max_msat;
|
||||||
channel->lease_chan_max_ppt = lease_chan_max_ppt;
|
channel->lease_chan_max_ppt = lease_chan_max_ppt;
|
||||||
|
|
||||||
|
tal_free(channel->blockheight_states);
|
||||||
|
channel->blockheight_states = new_height_states(channel,
|
||||||
|
channel->opener,
|
||||||
|
&lease_blockheight_start);
|
||||||
|
|
||||||
channel_set_last_tx(channel,
|
channel_set_last_tx(channel,
|
||||||
tal_steal(channel, remote_commit),
|
tal_steal(channel, remote_commit),
|
||||||
remote_commit_sig,
|
remote_commit_sig,
|
||||||
@ -1164,7 +1171,8 @@ wallet_update_channel(struct lightningd *ld,
|
|||||||
channel->lease_expiry,
|
channel->lease_expiry,
|
||||||
channel->lease_commit_sig,
|
channel->lease_commit_sig,
|
||||||
channel->lease_chan_max_msat,
|
channel->lease_chan_max_msat,
|
||||||
channel->lease_chan_max_ppt);
|
channel->lease_chan_max_ppt,
|
||||||
|
lease_blockheight_start);
|
||||||
wallet_inflight_add(ld->wallet, inflight);
|
wallet_inflight_add(ld->wallet, inflight);
|
||||||
|
|
||||||
return inflight;
|
return inflight;
|
||||||
@ -1186,6 +1194,7 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
const u8 *our_upfront_shutdown_script,
|
const u8 *our_upfront_shutdown_script,
|
||||||
const u8 *remote_upfront_shutdown_script,
|
const u8 *remote_upfront_shutdown_script,
|
||||||
struct wally_psbt *psbt STEALS,
|
struct wally_psbt *psbt STEALS,
|
||||||
|
const u32 lease_blockheight_start,
|
||||||
const u32 lease_expiry,
|
const u32 lease_expiry,
|
||||||
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
|
||||||
const u32 lease_chan_max_msat,
|
const u32 lease_chan_max_msat,
|
||||||
@ -1257,6 +1266,9 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
channel->first_blocknum = get_block_height(ld->topology);
|
channel->first_blocknum = get_block_height(ld->topology);
|
||||||
|
|
||||||
/* Update lease info for channel */
|
/* Update lease info for channel */
|
||||||
|
channel->blockheight_states = new_height_states(channel,
|
||||||
|
channel->opener,
|
||||||
|
&lease_blockheight_start);
|
||||||
channel->lease_expiry = lease_expiry;
|
channel->lease_expiry = lease_expiry;
|
||||||
|
|
||||||
tal_free(channel->lease_commit_sig);
|
tal_free(channel->lease_commit_sig);
|
||||||
@ -1281,7 +1293,8 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
channel->lease_expiry,
|
channel->lease_expiry,
|
||||||
channel->lease_commit_sig,
|
channel->lease_commit_sig,
|
||||||
channel->lease_chan_max_msat,
|
channel->lease_chan_max_msat,
|
||||||
channel->lease_chan_max_ppt);
|
channel->lease_chan_max_ppt,
|
||||||
|
lease_blockheight_start);
|
||||||
wallet_inflight_add(ld->wallet, inflight);
|
wallet_inflight_add(ld->wallet, inflight);
|
||||||
|
|
||||||
return inflight;
|
return inflight;
|
||||||
@ -2837,7 +2850,7 @@ static void handle_commit_received(struct subd *dualopend,
|
|||||||
struct bitcoin_txid funding_txid;
|
struct bitcoin_txid funding_txid;
|
||||||
u16 funding_outnum, lease_chan_max_ppt;
|
u16 funding_outnum, lease_chan_max_ppt;
|
||||||
u32 feerate_funding, feerate_commitment, lease_expiry,
|
u32 feerate_funding, feerate_commitment, lease_expiry,
|
||||||
lease_chan_max_msat;
|
lease_chan_max_msat, lease_blockheight_start;
|
||||||
struct amount_sat total_funding, funding_ours;
|
struct amount_sat total_funding, funding_ours;
|
||||||
u8 *remote_upfront_shutdown_script,
|
u8 *remote_upfront_shutdown_script,
|
||||||
*local_upfront_shutdown_script;
|
*local_upfront_shutdown_script;
|
||||||
@ -2870,6 +2883,7 @@ static void handle_commit_received(struct subd *dualopend,
|
|||||||
&feerate_commitment,
|
&feerate_commitment,
|
||||||
&local_upfront_shutdown_script,
|
&local_upfront_shutdown_script,
|
||||||
&remote_upfront_shutdown_script,
|
&remote_upfront_shutdown_script,
|
||||||
|
&lease_blockheight_start,
|
||||||
&lease_expiry,
|
&lease_expiry,
|
||||||
&lease_commit_sig,
|
&lease_commit_sig,
|
||||||
&lease_chan_max_msat,
|
&lease_chan_max_msat,
|
||||||
@ -2915,6 +2929,7 @@ static void handle_commit_received(struct subd *dualopend,
|
|||||||
local_upfront_shutdown_script,
|
local_upfront_shutdown_script,
|
||||||
remote_upfront_shutdown_script,
|
remote_upfront_shutdown_script,
|
||||||
psbt,
|
psbt,
|
||||||
|
lease_blockheight_start,
|
||||||
lease_expiry,
|
lease_expiry,
|
||||||
lease_commit_sig,
|
lease_commit_sig,
|
||||||
lease_chan_max_msat,
|
lease_chan_max_msat,
|
||||||
@ -2951,7 +2966,8 @@ static void handle_commit_received(struct subd *dualopend,
|
|||||||
lease_expiry,
|
lease_expiry,
|
||||||
lease_commit_sig,
|
lease_commit_sig,
|
||||||
lease_chan_max_msat,
|
lease_chan_max_msat,
|
||||||
lease_chan_max_ppt))) {
|
lease_chan_max_ppt,
|
||||||
|
lease_blockheight_start))) {
|
||||||
channel_internal_error(channel,
|
channel_internal_error(channel,
|
||||||
"wallet_update_channel failed"
|
"wallet_update_channel failed"
|
||||||
" (chan %s)",
|
" (chan %s)",
|
||||||
@ -3224,7 +3240,7 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
struct per_peer_state *pps,
|
struct per_peer_state *pps,
|
||||||
struct channel *channel)
|
struct channel *channel)
|
||||||
{
|
{
|
||||||
u32 max_to_self_delay;
|
u32 max_to_self_delay, blockheight;
|
||||||
struct amount_msat min_effective_htlc_capacity;
|
struct amount_msat min_effective_htlc_capacity;
|
||||||
struct channel_config unused_config;
|
struct channel_config unused_config;
|
||||||
struct channel_inflight *inflight;
|
struct channel_inflight *inflight;
|
||||||
@ -3268,6 +3284,8 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
|
|
||||||
inflight = channel_current_inflight(channel);
|
inflight = channel_current_inflight(channel);
|
||||||
assert(inflight);
|
assert(inflight);
|
||||||
|
blockheight = get_blockheight(channel->blockheight_states,
|
||||||
|
channel->opener, LOCAL);
|
||||||
|
|
||||||
msg = towire_dualopend_reinit(NULL,
|
msg = towire_dualopend_reinit(NULL,
|
||||||
chainparams,
|
chainparams,
|
||||||
@ -3301,6 +3319,7 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
inflight->remote_tx_sigs,
|
inflight->remote_tx_sigs,
|
||||||
channel->fee_states,
|
channel->fee_states,
|
||||||
channel->channel_flags,
|
channel->channel_flags,
|
||||||
|
blockheight,
|
||||||
inflight->lease_expiry,
|
inflight->lease_expiry,
|
||||||
inflight->lease_commit_sig,
|
inflight->lease_commit_sig,
|
||||||
inflight->lease_chan_max_msat,
|
inflight->lease_chan_max_msat,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/addr.h>
|
#include <common/addr.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
@ -105,6 +106,7 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
s64 final_key_idx;
|
s64 final_key_idx;
|
||||||
u64 static_remotekey_start;
|
u64 static_remotekey_start;
|
||||||
bool option_anchor_outputs;
|
bool option_anchor_outputs;
|
||||||
|
u32 lease_start_blockheight = 0; /* No leases on v1 */
|
||||||
|
|
||||||
/* We cannot both be the fundee *and* have a `fundchannel_start`
|
/* We cannot both be the fundee *and* have a `fundchannel_start`
|
||||||
* command running!
|
* command running!
|
||||||
@ -217,6 +219,8 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
NUM_SIDES, /* closer not yet known */
|
NUM_SIDES, /* closer not yet known */
|
||||||
uc->fc ? REASON_USER : REASON_REMOTE,
|
uc->fc ? REASON_USER : REASON_REMOTE,
|
||||||
NULL,
|
NULL,
|
||||||
|
take(new_height_states(NULL, uc->fc ? LOCAL : REMOTE,
|
||||||
|
&lease_start_blockheight)),
|
||||||
0, NULL, 0, 0); /* No leases on v1s */
|
0, NULL, 0, 0); /* No leases on v1s */
|
||||||
|
|
||||||
/* Now we finally put it in the database. */
|
/* Now we finally put it in the database. */
|
||||||
|
@ -1352,6 +1352,11 @@ static void update_channel_from_inflight(struct lightningd *ld,
|
|||||||
channel->lease_chan_max_msat = inflight->lease_chan_max_msat;
|
channel->lease_chan_max_msat = inflight->lease_chan_max_msat;
|
||||||
channel->lease_chan_max_ppt = inflight->lease_chan_max_ppt;
|
channel->lease_chan_max_ppt = inflight->lease_chan_max_ppt;
|
||||||
|
|
||||||
|
tal_free(channel->blockheight_states);
|
||||||
|
channel->blockheight_states = new_height_states(channel,
|
||||||
|
channel->opener,
|
||||||
|
&inflight->lease_blockheight_start);
|
||||||
|
|
||||||
/* Make a 'clone' of this tx */
|
/* Make a 'clone' of this tx */
|
||||||
psbt_copy = clone_psbt(channel, inflight->last_tx->psbt);
|
psbt_copy = clone_psbt(channel, inflight->last_tx->psbt);
|
||||||
channel_set_last_tx(channel,
|
channel_set_last_tx(channel,
|
||||||
|
@ -454,6 +454,11 @@ void merkle_tlv(const struct tlv_field *fields UNNEEDED, struct sha256 *merkle U
|
|||||||
struct bolt11 *new_bolt11(const tal_t *ctx UNNEEDED,
|
struct bolt11 *new_bolt11(const tal_t *ctx UNNEEDED,
|
||||||
const struct amount_msat *msat TAKES UNNEEDED)
|
const struct amount_msat *msat TAKES UNNEEDED)
|
||||||
{ fprintf(stderr, "new_bolt11 called!\n"); abort(); }
|
{ fprintf(stderr, "new_bolt11 called!\n"); abort(); }
|
||||||
|
/* Generated stub for new_height_states */
|
||||||
|
struct height_states *new_height_states(const tal_t *ctx UNNEEDED,
|
||||||
|
enum side opener UNNEEDED,
|
||||||
|
const u32 *blockheight UNNEEDED)
|
||||||
|
{ fprintf(stderr, "new_height_states called!\n"); abort(); }
|
||||||
/* Generated stub for new_reltimer_ */
|
/* Generated stub for new_reltimer_ */
|
||||||
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
||||||
const tal_t *ctx UNNEEDED,
|
const tal_t *ctx UNNEEDED,
|
||||||
|
2
onchaind/onchaind_wiregen.c
generated
2
onchaind/onchaind_wiregen.c
generated
@ -637,4 +637,4 @@ bool fromwire_onchaind_notify_coin_mvt(const void *p, struct chain_coin_mvt *mvt
|
|||||||
fromwire_chain_coin_mvt(&cursor, &plen, mvt);
|
fromwire_chain_coin_mvt(&cursor, &plen, mvt);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:746e39c14fccea8ff63ee097aa2b742ff0cdb63bd6dfaecd02b8b1c9fab58376
|
// SHA256STAMP:40630b923c5c303627b75b8ca663b0d8a060039d2171571f6ecab580695dfdba
|
||||||
|
2
onchaind/onchaind_wiregen.h
generated
2
onchaind/onchaind_wiregen.h
generated
@ -161,4 +161,4 @@ bool fromwire_onchaind_notify_coin_mvt(const void *p, struct chain_coin_mvt *mvt
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_ONCHAIND_ONCHAIND_WIREGEN_H */
|
#endif /* LIGHTNING_ONCHAIND_ONCHAIND_WIREGEN_H */
|
||||||
// SHA256STAMP:746e39c14fccea8ff63ee097aa2b742ff0cdb63bd6dfaecd02b8b1c9fab58376
|
// SHA256STAMP:40630b923c5c303627b75b8ca663b0d8a060039d2171571f6ecab580695dfdba
|
||||||
|
@ -36,6 +36,7 @@ OPENINGD_COMMON_OBJS := \
|
|||||||
common/bigsize.o \
|
common/bigsize.o \
|
||||||
common/billboard.o \
|
common/billboard.o \
|
||||||
common/bip32.o \
|
common/bip32.o \
|
||||||
|
common/blockheight_states.o \
|
||||||
common/channel_config.o \
|
common/channel_config.o \
|
||||||
common/channel_id.o \
|
common/channel_id.o \
|
||||||
common/crypto_state.o \
|
common/crypto_state.o \
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
#include <common/billboard.h>
|
#include <common/billboard.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/channel_id.h>
|
#include <common/channel_id.h>
|
||||||
#include <common/crypto_sync.h>
|
#include <common/crypto_sync.h>
|
||||||
@ -124,6 +125,9 @@ struct tx_state {
|
|||||||
/* Rates that we're using for this open... */
|
/* Rates that we're using for this open... */
|
||||||
struct lease_rates *rates;
|
struct lease_rates *rates;
|
||||||
|
|
||||||
|
/* Lease blockheight start */
|
||||||
|
u32 blockheight;
|
||||||
|
|
||||||
/* If delay til the channel funds lease expires */
|
/* If delay til the channel funds lease expires */
|
||||||
u32 lease_expiry;
|
u32 lease_expiry;
|
||||||
|
|
||||||
@ -144,6 +148,7 @@ static struct tx_state *new_tx_state(const tal_t *ctx)
|
|||||||
tx_state->remote_funding_sigs_rcvd = false;
|
tx_state->remote_funding_sigs_rcvd = false;
|
||||||
|
|
||||||
tx_state->lease_expiry = 0;
|
tx_state->lease_expiry = 0;
|
||||||
|
tx_state->blockheight = 0;
|
||||||
tx_state->lease_commit_sig = NULL;
|
tx_state->lease_commit_sig = NULL;
|
||||||
tx_state->lease_chan_max_msat = 0;
|
tx_state->lease_chan_max_msat = 0;
|
||||||
tx_state->lease_chan_max_ppt = 0;
|
tx_state->lease_chan_max_ppt = 0;
|
||||||
@ -1697,6 +1702,8 @@ static void revert_channel_state(struct state *state)
|
|||||||
&tx_state->funding_txid,
|
&tx_state->funding_txid,
|
||||||
tx_state->funding_txout,
|
tx_state->funding_txout,
|
||||||
state->minimum_depth,
|
state->minimum_depth,
|
||||||
|
take(new_height_states(NULL, opener,
|
||||||
|
&tx_state->blockheight)),
|
||||||
tx_state->lease_expiry,
|
tx_state->lease_expiry,
|
||||||
total,
|
total,
|
||||||
our_msats,
|
our_msats,
|
||||||
@ -1796,6 +1803,9 @@ static u8 *accepter_commits(struct state *state,
|
|||||||
&tx_state->funding_txid,
|
&tx_state->funding_txid,
|
||||||
tx_state->funding_txout,
|
tx_state->funding_txout,
|
||||||
state->minimum_depth,
|
state->minimum_depth,
|
||||||
|
take(new_height_states(NULL, REMOTE,
|
||||||
|
&tx_state->blockheight)),
|
||||||
|
|
||||||
tx_state->lease_expiry,
|
tx_state->lease_expiry,
|
||||||
total,
|
total,
|
||||||
our_msats,
|
our_msats,
|
||||||
@ -1922,6 +1932,7 @@ static u8 *accepter_commits(struct state *state,
|
|||||||
state->feerate_per_kw_commitment,
|
state->feerate_per_kw_commitment,
|
||||||
state->upfront_shutdown_script[LOCAL],
|
state->upfront_shutdown_script[LOCAL],
|
||||||
state->upfront_shutdown_script[REMOTE],
|
state->upfront_shutdown_script[REMOTE],
|
||||||
|
tx_state->blockheight,
|
||||||
tx_state->lease_expiry,
|
tx_state->lease_expiry,
|
||||||
tx_state->lease_commit_sig,
|
tx_state->lease_commit_sig,
|
||||||
tx_state->lease_chan_max_msat,
|
tx_state->lease_chan_max_msat,
|
||||||
@ -2003,7 +2014,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
char *err_reason;
|
char *err_reason;
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
struct amount_sat total, requested_amt, lease_fee;
|
struct amount_sat total, requested_amt, lease_fee;
|
||||||
u32 lease_blockheight_start;
|
|
||||||
enum dualopend_wire msg_type;
|
enum dualopend_wire msg_type;
|
||||||
struct tx_state *tx_state = state->tx_state;
|
struct tx_state *tx_state = state->tx_state;
|
||||||
|
|
||||||
@ -2043,12 +2053,10 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
/* FIXME: Do we support this? */
|
/* FIXME: Do we support this? */
|
||||||
requested_amt
|
requested_amt
|
||||||
= amount_sat(open_tlv->request_funds->requested_sats);
|
= amount_sat(open_tlv->request_funds->requested_sats);
|
||||||
lease_blockheight_start
|
tx_state->blockheight
|
||||||
= open_tlv->request_funds->blockheight;
|
= open_tlv->request_funds->blockheight;
|
||||||
} else {
|
} else
|
||||||
requested_amt = AMOUNT_SAT(0);
|
requested_amt = AMOUNT_SAT(0);
|
||||||
lease_blockheight_start = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* BOLT-* #2
|
/* BOLT-* #2
|
||||||
* If the peer's revocation basepoint is unknown (e.g.
|
* If the peer's revocation basepoint is unknown (e.g.
|
||||||
@ -2115,7 +2123,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
tx_state->tx_locktime,
|
tx_state->tx_locktime,
|
||||||
state->upfront_shutdown_script[REMOTE],
|
state->upfront_shutdown_script[REMOTE],
|
||||||
requested_amt,
|
requested_amt,
|
||||||
lease_blockheight_start);
|
tx_state->blockheight);
|
||||||
|
|
||||||
wire_sync_write(REQ_FD, take(msg));
|
wire_sync_write(REQ_FD, take(msg));
|
||||||
msg = wire_sync_read(tmpctx, REQ_FD);
|
msg = wire_sync_read(tmpctx, REQ_FD);
|
||||||
@ -2228,7 +2236,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
if (open_tlv->request_funds && tx_state->rates)
|
if (open_tlv->request_funds && tx_state->rates)
|
||||||
accept_tlv_add_offer(a_tlv, tx_state, tx_state->rates,
|
accept_tlv_add_offer(a_tlv, tx_state, tx_state->rates,
|
||||||
state->our_funding_pubkey,
|
state->our_funding_pubkey,
|
||||||
lease_blockheight_start);
|
tx_state->blockheight);
|
||||||
|
|
||||||
|
|
||||||
msg = towire_accept_channel2(tmpctx, &state->channel_id,
|
msg = towire_accept_channel2(tmpctx, &state->channel_id,
|
||||||
@ -2258,7 +2266,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
/* Add our fee to our amount now */
|
/* Add our fee to our amount now */
|
||||||
if (tx_state->rates) {
|
if (tx_state->rates) {
|
||||||
tx_state->lease_expiry
|
tx_state->lease_expiry
|
||||||
= lease_blockheight_start + LEASE_RATE_DURATION;
|
= tx_state->blockheight + LEASE_RATE_DURATION;
|
||||||
|
|
||||||
/* BOLT- #2:
|
/* BOLT- #2:
|
||||||
* The lease fee is added to the accepter's balance
|
* The lease fee is added to the accepter's balance
|
||||||
@ -2402,6 +2410,8 @@ static u8 *opener_commits(struct state *state,
|
|||||||
&tx_state->funding_txid,
|
&tx_state->funding_txid,
|
||||||
tx_state->funding_txout,
|
tx_state->funding_txout,
|
||||||
state->minimum_depth,
|
state->minimum_depth,
|
||||||
|
take(new_height_states(NULL, LOCAL,
|
||||||
|
&state->tx_state->blockheight)),
|
||||||
tx_state->lease_expiry,
|
tx_state->lease_expiry,
|
||||||
total,
|
total,
|
||||||
our_msats,
|
our_msats,
|
||||||
@ -2572,6 +2582,7 @@ static u8 *opener_commits(struct state *state,
|
|||||||
state->feerate_per_kw_commitment,
|
state->feerate_per_kw_commitment,
|
||||||
state->upfront_shutdown_script[LOCAL],
|
state->upfront_shutdown_script[LOCAL],
|
||||||
state->upfront_shutdown_script[REMOTE],
|
state->upfront_shutdown_script[REMOTE],
|
||||||
|
tx_state->blockheight,
|
||||||
tx_state->lease_expiry,
|
tx_state->lease_expiry,
|
||||||
tx_state->lease_commit_sig,
|
tx_state->lease_commit_sig,
|
||||||
tx_state->lease_chan_max_msat,
|
tx_state->lease_chan_max_msat,
|
||||||
@ -2586,7 +2597,6 @@ static void opener_start(struct state *state, u8 *msg)
|
|||||||
struct channel_id cid;
|
struct channel_id cid;
|
||||||
char *err_reason;
|
char *err_reason;
|
||||||
struct amount_sat total, requested_sats, lease_fee;
|
struct amount_sat total, requested_sats, lease_fee;
|
||||||
u32 current_blockheight;
|
|
||||||
bool dry_run;
|
bool dry_run;
|
||||||
struct tx_state *tx_state = state->tx_state;
|
struct tx_state *tx_state = state->tx_state;
|
||||||
|
|
||||||
@ -2598,7 +2608,7 @@ static void opener_start(struct state *state, u8 *msg)
|
|||||||
&tx_state->feerate_per_kw_funding,
|
&tx_state->feerate_per_kw_funding,
|
||||||
&state->channel_flags,
|
&state->channel_flags,
|
||||||
&requested_sats,
|
&requested_sats,
|
||||||
¤t_blockheight,
|
&tx_state->blockheight,
|
||||||
&dry_run))
|
&dry_run))
|
||||||
master_badmsg(WIRE_DUALOPEND_OPENER_INIT, msg);
|
master_badmsg(WIRE_DUALOPEND_OPENER_INIT, msg);
|
||||||
|
|
||||||
@ -2633,7 +2643,7 @@ static void opener_start(struct state *state, u8 *msg)
|
|||||||
tal(open_tlv, struct tlv_opening_tlvs_request_funds);
|
tal(open_tlv, struct tlv_opening_tlvs_request_funds);
|
||||||
open_tlv->request_funds->requested_sats =
|
open_tlv->request_funds->requested_sats =
|
||||||
requested_sats.satoshis; /* Raw: struct -> wire */
|
requested_sats.satoshis; /* Raw: struct -> wire */
|
||||||
open_tlv->request_funds->blockheight = current_blockheight;
|
open_tlv->request_funds->blockheight = tx_state->blockheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = towire_open_channel2(NULL,
|
msg = towire_open_channel2(NULL,
|
||||||
@ -2746,7 +2756,7 @@ static void opener_start(struct state *state, u8 *msg)
|
|||||||
char *err_msg;
|
char *err_msg;
|
||||||
struct lease_rates *rates = &a_tlv->will_fund->lease_rates;
|
struct lease_rates *rates = &a_tlv->will_fund->lease_rates;
|
||||||
|
|
||||||
tx_state->lease_expiry = current_blockheight + LEASE_RATE_DURATION;
|
tx_state->lease_expiry = tx_state->blockheight + LEASE_RATE_DURATION;
|
||||||
|
|
||||||
msg = towire_dualopend_validate_lease(NULL,
|
msg = towire_dualopend_validate_lease(NULL,
|
||||||
&a_tlv->will_fund->signature,
|
&a_tlv->will_fund->signature,
|
||||||
@ -3785,6 +3795,7 @@ int main(int argc, char *argv[])
|
|||||||
&state->tx_state->remote_funding_sigs_rcvd,
|
&state->tx_state->remote_funding_sigs_rcvd,
|
||||||
&fee_states,
|
&fee_states,
|
||||||
&state->channel_flags,
|
&state->channel_flags,
|
||||||
|
&state->tx_state->blockheight,
|
||||||
&state->tx_state->lease_expiry,
|
&state->tx_state->lease_expiry,
|
||||||
&state->tx_state->lease_commit_sig,
|
&state->tx_state->lease_commit_sig,
|
||||||
&state->tx_state->lease_chan_max_msat,
|
&state->tx_state->lease_chan_max_msat,
|
||||||
@ -3797,6 +3808,8 @@ int main(int argc, char *argv[])
|
|||||||
&state->tx_state->funding_txid,
|
&state->tx_state->funding_txid,
|
||||||
state->tx_state->funding_txout,
|
state->tx_state->funding_txout,
|
||||||
state->minimum_depth,
|
state->minimum_depth,
|
||||||
|
take(new_height_states(NULL, opener,
|
||||||
|
&state->tx_state->blockheight)),
|
||||||
state->tx_state->lease_expiry,
|
state->tx_state->lease_expiry,
|
||||||
total_funding,
|
total_funding,
|
||||||
our_msat,
|
our_msat,
|
||||||
|
@ -65,6 +65,7 @@ msgdata,dualopend_reinit,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
|
|||||||
msgdata,dualopend_reinit,remote_funding_sigs_received,bool,
|
msgdata,dualopend_reinit,remote_funding_sigs_received,bool,
|
||||||
msgdata,dualopend_reinit,fee_states,fee_states,
|
msgdata,dualopend_reinit,fee_states,fee_states,
|
||||||
msgdata,dualopend_reinit,channel_flags,u8,
|
msgdata,dualopend_reinit,channel_flags,u8,
|
||||||
|
msgdata,dualopend_reinit,lease_start_blockheight,u32,
|
||||||
msgdata,dualopend_reinit,lease_expiry,u32,
|
msgdata,dualopend_reinit,lease_expiry,u32,
|
||||||
msgdata,dualopend_reinit,lease_commit_sig,?secp256k1_ecdsa_signature,
|
msgdata,dualopend_reinit,lease_commit_sig,?secp256k1_ecdsa_signature,
|
||||||
msgdata,dualopend_reinit,lease_chan_max_msat,u32,
|
msgdata,dualopend_reinit,lease_chan_max_msat,u32,
|
||||||
@ -146,6 +147,7 @@ msgdata,dualopend_commit_rcvd,local_shutdown_len,u16,
|
|||||||
msgdata,dualopend_commit_rcvd,local_shutdown_scriptpubkey,u8,local_shutdown_len
|
msgdata,dualopend_commit_rcvd,local_shutdown_scriptpubkey,u8,local_shutdown_len
|
||||||
msgdata,dualopend_commit_rcvd,remote_shutdown_len,u16,
|
msgdata,dualopend_commit_rcvd,remote_shutdown_len,u16,
|
||||||
msgdata,dualopend_commit_rcvd,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
|
msgdata,dualopend_commit_rcvd,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
|
||||||
|
msgdata,dualopend_commit_rcvd,lease_start_blockheight,u32,
|
||||||
msgdata,dualopend_commit_rcvd,lease_expiry,u32,
|
msgdata,dualopend_commit_rcvd,lease_expiry,u32,
|
||||||
msgdata,dualopend_commit_rcvd,lease_commit_sig,?secp256k1_ecdsa_signature,
|
msgdata,dualopend_commit_rcvd,lease_commit_sig,?secp256k1_ecdsa_signature,
|
||||||
msgdata,dualopend_commit_rcvd,lease_chan_max_msat,u32,
|
msgdata,dualopend_commit_rcvd,lease_chan_max_msat,u32,
|
||||||
|
Can't render this file because it has a wrong number of fields in line 15.
|
14
openingd/dualopend_wiregen.c
generated
14
openingd/dualopend_wiregen.c
generated
@ -152,7 +152,7 @@ bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chain
|
|||||||
|
|
||||||
/* WIRE: DUALOPEND_REINIT */
|
/* WIRE: DUALOPEND_REINIT */
|
||||||
/* master-dualopend: peer has reconnected */
|
/* master-dualopend: peer has reconnected */
|
||||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt)
|
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, u32 lease_start_blockheight, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt)
|
||||||
{
|
{
|
||||||
u16 their_init_features_len = tal_count(their_init_features);
|
u16 their_init_features_len = tal_count(their_init_features);
|
||||||
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
|
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
|
||||||
@ -194,6 +194,7 @@ u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainpar
|
|||||||
towire_bool(&p, remote_funding_sigs_received);
|
towire_bool(&p, remote_funding_sigs_received);
|
||||||
towire_fee_states(&p, fee_states);
|
towire_fee_states(&p, fee_states);
|
||||||
towire_u8(&p, channel_flags);
|
towire_u8(&p, channel_flags);
|
||||||
|
towire_u32(&p, lease_start_blockheight);
|
||||||
towire_u32(&p, lease_expiry);
|
towire_u32(&p, lease_expiry);
|
||||||
if (!lease_commit_sig)
|
if (!lease_commit_sig)
|
||||||
towire_bool(&p, false);
|
towire_bool(&p, false);
|
||||||
@ -206,7 +207,7 @@ u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainpar
|
|||||||
|
|
||||||
return memcheck(p, tal_count(p));
|
return memcheck(p, tal_count(p));
|
||||||
}
|
}
|
||||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt)
|
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u32 *lease_start_blockheight, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt)
|
||||||
{
|
{
|
||||||
u16 their_init_features_len;
|
u16 their_init_features_len;
|
||||||
u16 local_shutdown_len;
|
u16 local_shutdown_len;
|
||||||
@ -257,6 +258,7 @@ bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct cha
|
|||||||
*remote_funding_sigs_received = fromwire_bool(&cursor, &plen);
|
*remote_funding_sigs_received = fromwire_bool(&cursor, &plen);
|
||||||
*fee_states = fromwire_fee_states(ctx, &cursor, &plen);
|
*fee_states = fromwire_fee_states(ctx, &cursor, &plen);
|
||||||
*channel_flags = fromwire_u8(&cursor, &plen);
|
*channel_flags = fromwire_u8(&cursor, &plen);
|
||||||
|
*lease_start_blockheight = fromwire_u32(&cursor, &plen);
|
||||||
*lease_expiry = fromwire_u32(&cursor, &plen);
|
*lease_expiry = fromwire_u32(&cursor, &plen);
|
||||||
if (!fromwire_bool(&cursor, &plen))
|
if (!fromwire_bool(&cursor, &plen))
|
||||||
*lease_commit_sig = NULL;
|
*lease_commit_sig = NULL;
|
||||||
@ -492,7 +494,7 @@ bool fromwire_dualopend_rbf_init(const tal_t *ctx, const void *p, struct amount_
|
|||||||
/* WIRE: DUALOPEND_COMMIT_RCVD */
|
/* WIRE: DUALOPEND_COMMIT_RCVD */
|
||||||
/* dualopend->master: ready to commit channel open to database and */
|
/* dualopend->master: ready to commit channel open to database and */
|
||||||
/* get some signatures for the funding_tx. */
|
/* get some signatures for the funding_tx. */
|
||||||
u8 *towire_dualopend_commit_rcvd(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *remote_first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct wally_psbt *psbt, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_sat our_funding_sats, u8 channel_flags, u32 feerate_per_kw_funding, u32 feerate_per_kw_commitment, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt)
|
u8 *towire_dualopend_commit_rcvd(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *remote_first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct wally_psbt *psbt, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_sat our_funding_sats, u8 channel_flags, u32 feerate_per_kw_funding, u32 feerate_per_kw_commitment, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, u32 lease_start_blockheight, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt)
|
||||||
{
|
{
|
||||||
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
|
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
|
||||||
u16 remote_shutdown_len = tal_count(remote_shutdown_scriptpubkey);
|
u16 remote_shutdown_len = tal_count(remote_shutdown_scriptpubkey);
|
||||||
@ -526,6 +528,7 @@ u8 *towire_dualopend_commit_rcvd(const tal_t *ctx, const struct channel_config *
|
|||||||
towire_u8_array(&p, local_shutdown_scriptpubkey, local_shutdown_len);
|
towire_u8_array(&p, local_shutdown_scriptpubkey, local_shutdown_len);
|
||||||
towire_u16(&p, remote_shutdown_len);
|
towire_u16(&p, remote_shutdown_len);
|
||||||
towire_u8_array(&p, remote_shutdown_scriptpubkey, remote_shutdown_len);
|
towire_u8_array(&p, remote_shutdown_scriptpubkey, remote_shutdown_len);
|
||||||
|
towire_u32(&p, lease_start_blockheight);
|
||||||
towire_u32(&p, lease_expiry);
|
towire_u32(&p, lease_expiry);
|
||||||
if (!lease_commit_sig)
|
if (!lease_commit_sig)
|
||||||
towire_bool(&p, false);
|
towire_bool(&p, false);
|
||||||
@ -538,7 +541,7 @@ u8 *towire_dualopend_commit_rcvd(const tal_t *ctx, const struct channel_config *
|
|||||||
|
|
||||||
return memcheck(p, tal_count(p));
|
return memcheck(p, tal_count(p));
|
||||||
}
|
}
|
||||||
bool fromwire_dualopend_commit_rcvd(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **remote_first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct wally_psbt **psbt, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_sat *our_funding_sats, u8 *channel_flags, u32 *feerate_per_kw_funding, u32 *feerate_per_kw_commitment, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt)
|
bool fromwire_dualopend_commit_rcvd(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **remote_first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct wally_psbt **psbt, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_sat *our_funding_sats, u8 *channel_flags, u32 *feerate_per_kw_funding, u32 *feerate_per_kw_commitment, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, u32 *lease_start_blockheight, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt)
|
||||||
{
|
{
|
||||||
u16 local_shutdown_len;
|
u16 local_shutdown_len;
|
||||||
u16 remote_shutdown_len;
|
u16 remote_shutdown_len;
|
||||||
@ -579,6 +582,7 @@ bool fromwire_dualopend_commit_rcvd(const tal_t *ctx, const void *p, struct chan
|
|||||||
// 2nd case remote_shutdown_scriptpubkey
|
// 2nd case remote_shutdown_scriptpubkey
|
||||||
*remote_shutdown_scriptpubkey = remote_shutdown_len ? tal_arr(ctx, u8, remote_shutdown_len) : NULL;
|
*remote_shutdown_scriptpubkey = remote_shutdown_len ? tal_arr(ctx, u8, remote_shutdown_len) : NULL;
|
||||||
fromwire_u8_array(&cursor, &plen, *remote_shutdown_scriptpubkey, remote_shutdown_len);
|
fromwire_u8_array(&cursor, &plen, *remote_shutdown_scriptpubkey, remote_shutdown_len);
|
||||||
|
*lease_start_blockheight = fromwire_u32(&cursor, &plen);
|
||||||
*lease_expiry = fromwire_u32(&cursor, &plen);
|
*lease_expiry = fromwire_u32(&cursor, &plen);
|
||||||
if (!fromwire_bool(&cursor, &plen))
|
if (!fromwire_bool(&cursor, &plen))
|
||||||
*lease_commit_sig = NULL;
|
*lease_commit_sig = NULL;
|
||||||
@ -1074,4 +1078,4 @@ bool fromwire_dualopend_validate_lease_reply(const tal_t *ctx, const void *p, wi
|
|||||||
}
|
}
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:ee275d023d9d8ba7e520d321908da0228f76e7ca0d6f76908d17e967177f16c8
|
// SHA256STAMP:65d1bedd1e05436c5474d298811fbb9c3fc96ac4e84bef8081c4eee55de286ad
|
||||||
|
10
openingd/dualopend_wiregen.h
generated
10
openingd/dualopend_wiregen.h
generated
@ -98,8 +98,8 @@ bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chain
|
|||||||
|
|
||||||
/* WIRE: DUALOPEND_REINIT */
|
/* WIRE: DUALOPEND_REINIT */
|
||||||
/* master-dualopend: peer has reconnected */
|
/* master-dualopend: peer has reconnected */
|
||||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt);
|
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, u32 lease_start_blockheight, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt);
|
||||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt);
|
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u32 *lease_start_blockheight, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt);
|
||||||
|
|
||||||
/* WIRE: DUALOPEND_GOT_OFFER */
|
/* WIRE: DUALOPEND_GOT_OFFER */
|
||||||
/* dualopend->master: they offered channel */
|
/* dualopend->master: they offered channel */
|
||||||
@ -139,8 +139,8 @@ bool fromwire_dualopend_rbf_init(const tal_t *ctx, const void *p, struct amount_
|
|||||||
/* WIRE: DUALOPEND_COMMIT_RCVD */
|
/* WIRE: DUALOPEND_COMMIT_RCVD */
|
||||||
/* dualopend->master: ready to commit channel open to database and */
|
/* dualopend->master: ready to commit channel open to database and */
|
||||||
/* get some signatures for the funding_tx. */
|
/* get some signatures for the funding_tx. */
|
||||||
u8 *towire_dualopend_commit_rcvd(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *remote_first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct wally_psbt *psbt, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_sat our_funding_sats, u8 channel_flags, u32 feerate_per_kw_funding, u32 feerate_per_kw_commitment, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt);
|
u8 *towire_dualopend_commit_rcvd(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *remote_first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct wally_psbt *psbt, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_sat our_funding_sats, u8 channel_flags, u32 feerate_per_kw_funding, u32 feerate_per_kw_commitment, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, u32 lease_start_blockheight, u32 lease_expiry, const secp256k1_ecdsa_signature *lease_commit_sig, u32 lease_chan_max_msat, u16 lease_chan_max_ppt);
|
||||||
bool fromwire_dualopend_commit_rcvd(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **remote_first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct wally_psbt **psbt, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_sat *our_funding_sats, u8 *channel_flags, u32 *feerate_per_kw_funding, u32 *feerate_per_kw_commitment, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt);
|
bool fromwire_dualopend_commit_rcvd(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **remote_first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct wally_psbt **psbt, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_sat *our_funding_sats, u8 *channel_flags, u32 *feerate_per_kw_funding, u32 *feerate_per_kw_commitment, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, u32 *lease_start_blockheight, u32 *lease_expiry, secp256k1_ecdsa_signature **lease_commit_sig, u32 *lease_chan_max_msat, u16 *lease_chan_max_ppt);
|
||||||
|
|
||||||
/* WIRE: DUALOPEND_PSBT_CHANGED */
|
/* WIRE: DUALOPEND_PSBT_CHANGED */
|
||||||
/* dualopend->master: peer updated the psbt */
|
/* dualopend->master: peer updated the psbt */
|
||||||
@ -237,4 +237,4 @@ bool fromwire_dualopend_validate_lease_reply(const tal_t *ctx, const void *p, wi
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
||||||
// SHA256STAMP:ee275d023d9d8ba7e520d321908da0228f76e7ca0d6f76908d17e967177f16c8
|
// SHA256STAMP:65d1bedd1e05436c5474d298811fbb9c3fc96ac4e84bef8081c4eee55de286ad
|
||||||
|
@ -510,7 +510,7 @@ static bool funder_finalize_channel_setup(struct state *state,
|
|||||||
&state->funding_txid,
|
&state->funding_txid,
|
||||||
state->funding_txout,
|
state->funding_txout,
|
||||||
state->minimum_depth,
|
state->minimum_depth,
|
||||||
0, /* No lease lock */
|
NULL, 0, /* No channel lease */
|
||||||
state->funding,
|
state->funding,
|
||||||
local_msat,
|
local_msat,
|
||||||
take(new_fee_states(NULL, LOCAL,
|
take(new_fee_states(NULL, LOCAL,
|
||||||
@ -1001,7 +1001,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
|||||||
&state->funding_txid,
|
&state->funding_txid,
|
||||||
state->funding_txout,
|
state->funding_txout,
|
||||||
state->minimum_depth,
|
state->minimum_depth,
|
||||||
0, /* No channel lease */
|
NULL, 0, /* No channel lease */
|
||||||
state->funding,
|
state->funding,
|
||||||
state->push_msat,
|
state->push_msat,
|
||||||
take(new_fee_states(NULL, REMOTE,
|
take(new_fee_states(NULL, REMOTE,
|
||||||
|
2
openingd/openingd_wiregen.c
generated
2
openingd/openingd_wiregen.c
generated
@ -604,4 +604,4 @@ bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak)
|
|||||||
*leak = fromwire_bool(&cursor, &plen);
|
*leak = fromwire_bool(&cursor, &plen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:3dc596105e65c16cc549a7ae739c7e83ed11cce7d7effb206f317522ba741506
|
// SHA256STAMP:779aa98c325bc5c87c31b24767f45f22edd135b8e2be4fe3ca1282d91950f0c4
|
||||||
|
2
openingd/openingd_wiregen.h
generated
2
openingd/openingd_wiregen.h
generated
@ -128,4 +128,4 @@ bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak);
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H */
|
#endif /* LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H */
|
||||||
// SHA256STAMP:3dc596105e65c16cc549a7ae739c7e83ed11cce7d7effb206f317522ba741506
|
// SHA256STAMP:779aa98c325bc5c87c31b24767f45f22edd135b8e2be4fe3ca1282d91950f0c4
|
||||||
|
@ -34,7 +34,7 @@ void run(const uint8_t *data, size_t size)
|
|||||||
u32 funding_txout, minimum_depth;
|
u32 funding_txout, minimum_depth;
|
||||||
struct amount_sat funding, max;
|
struct amount_sat funding, max;
|
||||||
struct amount_msat local_msatoshi;
|
struct amount_msat local_msatoshi;
|
||||||
u32 feerate_per_kw;
|
u32 feerate_per_kw, blockheight, lease_expiry;
|
||||||
struct channel_config local, remote;
|
struct channel_config local, remote;
|
||||||
struct basepoints local_basepoints, remote_basepoints;
|
struct basepoints local_basepoints, remote_basepoints;
|
||||||
struct pubkey local_funding_pubkey, remote_funding_pubkey;
|
struct pubkey local_funding_pubkey, remote_funding_pubkey;
|
||||||
@ -51,6 +51,8 @@ void run(const uint8_t *data, size_t size)
|
|||||||
if (amount_sat_greater(funding, max))
|
if (amount_sat_greater(funding, max))
|
||||||
funding = max;
|
funding = max;
|
||||||
feerate_per_kw = fromwire_u32(&data, &size);
|
feerate_per_kw = fromwire_u32(&data, &size);
|
||||||
|
blockheight = fromwire_u32(&data, &size);
|
||||||
|
lease_expiry = fromwire_u32(&data, &size);
|
||||||
fromwire_channel_config(&data, &size, &local);
|
fromwire_channel_config(&data, &size, &local);
|
||||||
fromwire_channel_config(&data, &size, &remote);
|
fromwire_channel_config(&data, &size, &remote);
|
||||||
fromwire_basepoints(&data, &size, &local_basepoints);
|
fromwire_basepoints(&data, &size, &local_basepoints);
|
||||||
@ -66,12 +68,20 @@ void run(const uint8_t *data, size_t size)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (enum side opener = 0; opener < NUM_SIDES; opener++) {
|
for (enum side opener = 0; opener < NUM_SIDES; opener++) {
|
||||||
channel = new_initial_channel(tmpctx, &cid, &funding_txid, funding_txout,
|
channel = new_initial_channel(tmpctx, &cid, &funding_txid,
|
||||||
minimum_depth, funding, local_msatoshi,
|
funding_txout, minimum_depth,
|
||||||
take(new_fee_states(NULL, opener, &feerate_per_kw)),
|
take(new_height_states(NULL, opener,
|
||||||
&local, &remote, &local_basepoints,
|
&blockheight)),
|
||||||
&remote_basepoints, &local_funding_pubkey,
|
lease_expiry,
|
||||||
&remote_funding_pubkey, option_static_remotekey,
|
funding, local_msatoshi,
|
||||||
|
take(new_fee_states(NULL, opener,
|
||||||
|
&feerate_per_kw)),
|
||||||
|
&local, &remote,
|
||||||
|
&local_basepoints,
|
||||||
|
&remote_basepoints,
|
||||||
|
&local_funding_pubkey,
|
||||||
|
&remote_funding_pubkey,
|
||||||
|
option_static_remotekey,
|
||||||
option_anchor_outputs, opener);
|
option_anchor_outputs, opener);
|
||||||
|
|
||||||
/* TODO: make initial_channel_tx() work with ASAN.. */
|
/* TODO: make initial_channel_tx() work with ASAN.. */
|
||||||
|
@ -231,6 +231,7 @@ class Type(FieldSet):
|
|||||||
'bitcoin_tx_output',
|
'bitcoin_tx_output',
|
||||||
'exclude_entry',
|
'exclude_entry',
|
||||||
'fee_states',
|
'fee_states',
|
||||||
|
'height_states',
|
||||||
'onionreply',
|
'onionreply',
|
||||||
'feature_set',
|
'feature_set',
|
||||||
'onionmsg_path',
|
'onionmsg_path',
|
||||||
|
39
wallet/db.c
39
wallet/db.c
@ -62,6 +62,10 @@ static void fillin_missing_local_basepoints(struct lightningd *ld,
|
|||||||
struct db *db,
|
struct db *db,
|
||||||
const struct migration_context *mc);
|
const struct migration_context *mc);
|
||||||
|
|
||||||
|
static void fillin_missing_channel_blockheights(struct lightningd *ld,
|
||||||
|
struct db *db,
|
||||||
|
const struct migration_context *mc);
|
||||||
|
|
||||||
/* Do not reorder or remove elements from this array, it is used to
|
/* Do not reorder or remove elements from this array, it is used to
|
||||||
* migrate existing databases from a previous state, based on the
|
* migrate existing databases from a previous state, based on the
|
||||||
* string indices */
|
* string indices */
|
||||||
@ -732,10 +736,18 @@ static struct migration dbmigrations[] = {
|
|||||||
{SQL("ALTER TABLE channel_funding_inflights ADD lease_chan_max_msat BIGINT DEFAULT NULL"), NULL},
|
{SQL("ALTER TABLE channel_funding_inflights ADD lease_chan_max_msat BIGINT DEFAULT NULL"), NULL},
|
||||||
{SQL("ALTER TABLE channel_funding_inflights ADD lease_chan_max_ppt INTEGER DEFAULT NULL"), NULL},
|
{SQL("ALTER TABLE channel_funding_inflights ADD lease_chan_max_ppt INTEGER DEFAULT NULL"), NULL},
|
||||||
{SQL("ALTER TABLE channel_funding_inflights ADD lease_expiry INTEGER DEFAULT 0"), NULL},
|
{SQL("ALTER TABLE channel_funding_inflights ADD lease_expiry INTEGER DEFAULT 0"), NULL},
|
||||||
|
{SQL("ALTER TABLE channel_funding_inflights ADD lease_blockheight_start INTEGER DEFAULT 0"), NULL},
|
||||||
{SQL("ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL"), NULL},
|
{SQL("ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL"), NULL},
|
||||||
{SQL("ALTER TABLE channels ADD lease_chan_max_msat INTEGER DEFAULT NULL"), NULL},
|
{SQL("ALTER TABLE channels ADD lease_chan_max_msat INTEGER DEFAULT NULL"), NULL},
|
||||||
{SQL("ALTER TABLE channels ADD lease_chan_max_ppt INTEGER DEFAULT NULL"), NULL},
|
{SQL("ALTER TABLE channels ADD lease_chan_max_ppt INTEGER DEFAULT NULL"), NULL},
|
||||||
{SQL("ALTER TABLE channels ADD lease_expiry INTEGER DEFAULT 0"), NULL},
|
{SQL("ALTER TABLE channels ADD lease_expiry INTEGER DEFAULT 0"), NULL},
|
||||||
|
{SQL("CREATE TABLE channel_blockheights ("
|
||||||
|
" channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE,"
|
||||||
|
" hstate INTEGER,"
|
||||||
|
" blockheight INTEGER,"
|
||||||
|
" UNIQUE (channel_id, hstate)"
|
||||||
|
");"),
|
||||||
|
fillin_missing_channel_blockheights},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Leak tracking. */
|
/* Leak tracking. */
|
||||||
@ -1428,6 +1440,33 @@ static void fillin_missing_local_basepoints(struct lightningd *ld,
|
|||||||
tal_free(stmt);
|
tal_free(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* New 'channel_blockheights' table, every existing channel gets a
|
||||||
|
* 'initial blockheight' of 0 */
|
||||||
|
static void fillin_missing_channel_blockheights(struct lightningd *ld,
|
||||||
|
struct db *db,
|
||||||
|
const struct migration_context *mc)
|
||||||
|
{
|
||||||
|
struct db_stmt *stmt;
|
||||||
|
|
||||||
|
/* Set all existing channels to 0 */
|
||||||
|
/* If we're funder (LOCAL=0):
|
||||||
|
* Then our blockheight is set last (SENT_ADD_ACK_REVOCATION = 4) */
|
||||||
|
stmt = db_prepare_v2(db,
|
||||||
|
SQL("INSERT INTO channel_blockheights"
|
||||||
|
" (channel_id, hstate, blockheight)"
|
||||||
|
" SELECT id, 4, 0 FROM channels"
|
||||||
|
" WHERE funder = 0;"));
|
||||||
|
db_exec_prepared_v2(take(stmt));
|
||||||
|
/* If they're funder (REMOTE=1):
|
||||||
|
* Then their blockheight is last (RCVD_ADD_ACK_REVOCATION = 14) */
|
||||||
|
stmt = db_prepare_v2(db,
|
||||||
|
SQL("INSERT INTO channel_blockheights"
|
||||||
|
" (channel_id, hstate, blockheight)"
|
||||||
|
" SELECT id, 14, 0 FROM channels"
|
||||||
|
" WHERE funder = 1;"));
|
||||||
|
db_exec_prepared_v2(take(stmt));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
migrate_inflight_last_tx_to_psbt(struct lightningd *ld, struct db *db,
|
migrate_inflight_last_tx_to_psbt(struct lightningd *ld, struct db *db,
|
||||||
const struct migration_context *mc)
|
const struct migration_context *mc)
|
||||||
|
56
wallet/db_postgres_sqlgen.c
generated
56
wallet/db_postgres_sqlgen.c
generated
@ -980,6 +980,12 @@ struct db_query db_postgres_queries[] = {
|
|||||||
.placeholders = 0,
|
.placeholders = 0,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "ALTER TABLE channel_funding_inflights ADD lease_blockheight_start INTEGER DEFAULT 0",
|
||||||
|
.query = "ALTER TABLE channel_funding_inflights ADD lease_blockheight_start INTEGER DEFAULT 0",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL",
|
.name = "ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL",
|
||||||
.query = "ALTER TABLE channels ADD lease_commit_sig BYTEA DEFAULT NULL",
|
.query = "ALTER TABLE channels ADD lease_commit_sig BYTEA DEFAULT NULL",
|
||||||
@ -1004,6 +1010,12 @@ struct db_query db_postgres_queries[] = {
|
|||||||
.placeholders = 0,
|
.placeholders = 0,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "CREATE TABLE channel_blockheights ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, hstate INTEGER, blockheight INTEGER, UNIQUE (channel_id, hstate));",
|
||||||
|
.query = "CREATE TABLE channel_blockheights ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, hstate INTEGER, blockheight INTEGER, UNIQUE (channel_id, hstate));",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
||||||
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = $1",
|
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = $1",
|
||||||
@ -1100,6 +1112,18 @@ struct db_query db_postgres_queries[] = {
|
|||||||
.placeholders = 6,
|
.placeholders = 6,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 4, 0 FROM channels WHERE funder = 0;",
|
||||||
|
.query = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 4, 0 FROM channels WHERE funder = 0;",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 14, 0 FROM channels WHERE funder = 1;",
|
||||||
|
.query = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 14, 0 FROM channels WHERE funder = 1;",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
.name = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
||||||
.query = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
.query = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
||||||
@ -1341,9 +1365,15 @@ struct db_query db_postgres_queries[] = {
|
|||||||
.readonly = true,
|
.readonly = true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
.name = "SELECT hstate, blockheight FROM channel_blockheights WHERE channel_id = ?",
|
||||||
.query = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);",
|
.query = "SELECT hstate, blockheight FROM channel_blockheights WHERE channel_id = $1",
|
||||||
.placeholders = 9,
|
.placeholders = 1,
|
||||||
|
.readonly = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_expiry, lease_blockheight_start) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||||
|
.query = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_expiry, lease_blockheight_start) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);",
|
||||||
|
.placeholders = 14,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1359,8 +1389,8 @@ struct db_query db_postgres_queries[] = {
|
|||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate",
|
.name = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_blockheight_start FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate",
|
||||||
.query = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt FROM channel_funding_inflights WHERE channel_id = $1 ORDER BY funding_feerate",
|
.query = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_blockheight_start FROM channel_funding_inflights WHERE channel_id = $1 ORDER BY funding_feerate",
|
||||||
.placeholders = 1,
|
.placeholders = 1,
|
||||||
.readonly = true,
|
.readonly = true,
|
||||||
},
|
},
|
||||||
@ -1460,6 +1490,18 @@ struct db_query db_postgres_queries[] = {
|
|||||||
.placeholders = 3,
|
.placeholders = 3,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "DELETE FROM channel_blockheights WHERE channel_id=?",
|
||||||
|
.query = "DELETE FROM channel_blockheights WHERE channel_id=$1",
|
||||||
|
.placeholders = 1,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_blockheights VALUES(?, ?, ?)",
|
||||||
|
.query = "INSERT INTO channel_blockheights VALUES($1, $2, $3)",
|
||||||
|
.placeholders = 3,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "UPDATE channels SET last_sent_commit=? WHERE id=?",
|
.name = "UPDATE channels SET last_sent_commit=? WHERE id=?",
|
||||||
.query = "UPDATE channels SET last_sent_commit=$1 WHERE id=$2",
|
.query = "UPDATE channels SET last_sent_commit=$1 WHERE id=$2",
|
||||||
@ -1966,10 +2008,10 @@ struct db_query db_postgres_queries[] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DB_POSTGRES_QUERY_COUNT 326
|
#define DB_POSTGRES_QUERY_COUNT 333
|
||||||
|
|
||||||
#endif /* HAVE_POSTGRES */
|
#endif /* HAVE_POSTGRES */
|
||||||
|
|
||||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
|
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
|
||||||
|
|
||||||
// SHA256STAMP:85d581977cc3b124df4c81058cab78f13938dfa0cb4845526bb121e396bcf97d
|
// SHA256STAMP:1778bd4f49bef247c2b4789d1f7db3542fd606cbe186e299738aecbfbb2d44ae
|
||||||
|
56
wallet/db_sqlite3_sqlgen.c
generated
56
wallet/db_sqlite3_sqlgen.c
generated
@ -980,6 +980,12 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
.placeholders = 0,
|
.placeholders = 0,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "ALTER TABLE channel_funding_inflights ADD lease_blockheight_start INTEGER DEFAULT 0",
|
||||||
|
.query = "ALTER TABLE channel_funding_inflights ADD lease_blockheight_start INTEGER DEFAULT 0",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL",
|
.name = "ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL",
|
||||||
.query = "ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL",
|
.query = "ALTER TABLE channels ADD lease_commit_sig BLOB DEFAULT NULL",
|
||||||
@ -1004,6 +1010,12 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
.placeholders = 0,
|
.placeholders = 0,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "CREATE TABLE channel_blockheights ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, hstate INTEGER, blockheight INTEGER, UNIQUE (channel_id, hstate));",
|
||||||
|
.query = "CREATE TABLE channel_blockheights ( channel_id INTEGER REFERENCES channels(id) ON DELETE CASCADE, hstate INTEGER, blockheight INTEGER, UNIQUE (channel_id, hstate));",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
||||||
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
||||||
@ -1100,6 +1112,18 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
.placeholders = 6,
|
.placeholders = 6,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 4, 0 FROM channels WHERE funder = 0;",
|
||||||
|
.query = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 4, 0 FROM channels WHERE funder = 0;",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 14, 0 FROM channels WHERE funder = 1;",
|
||||||
|
.query = "INSERT INTO channel_blockheights (channel_id, hstate, blockheight) SELECT id, 14, 0 FROM channels WHERE funder = 1;",
|
||||||
|
.placeholders = 0,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
.name = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
||||||
.query = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
.query = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
|
||||||
@ -1341,9 +1365,15 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
.readonly = true,
|
.readonly = true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
.name = "SELECT hstate, blockheight FROM channel_blockheights WHERE channel_id = ?",
|
||||||
.query = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
.query = "SELECT hstate, blockheight FROM channel_blockheights WHERE channel_id = ?",
|
||||||
.placeholders = 9,
|
.placeholders = 1,
|
||||||
|
.readonly = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_expiry, lease_blockheight_start) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||||
|
.query = "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_expiry, lease_blockheight_start) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||||
|
.placeholders = 14,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1359,8 +1389,8 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate",
|
.name = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_blockheight_start FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate",
|
||||||
.query = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate",
|
.query = "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_blockheight_start FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate",
|
||||||
.placeholders = 1,
|
.placeholders = 1,
|
||||||
.readonly = true,
|
.readonly = true,
|
||||||
},
|
},
|
||||||
@ -1460,6 +1490,18 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
.placeholders = 3,
|
.placeholders = 3,
|
||||||
.readonly = false,
|
.readonly = false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "DELETE FROM channel_blockheights WHERE channel_id=?",
|
||||||
|
.query = "DELETE FROM channel_blockheights WHERE channel_id=?",
|
||||||
|
.placeholders = 1,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "INSERT INTO channel_blockheights VALUES(?, ?, ?)",
|
||||||
|
.query = "INSERT INTO channel_blockheights VALUES(?, ?, ?)",
|
||||||
|
.placeholders = 3,
|
||||||
|
.readonly = false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "UPDATE channels SET last_sent_commit=? WHERE id=?",
|
.name = "UPDATE channels SET last_sent_commit=? WHERE id=?",
|
||||||
.query = "UPDATE channels SET last_sent_commit=? WHERE id=?",
|
.query = "UPDATE channels SET last_sent_commit=? WHERE id=?",
|
||||||
@ -1966,10 +2008,10 @@ struct db_query db_sqlite3_queries[] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DB_SQLITE3_QUERY_COUNT 326
|
#define DB_SQLITE3_QUERY_COUNT 333
|
||||||
|
|
||||||
#endif /* HAVE_SQLITE3 */
|
#endif /* HAVE_SQLITE3 */
|
||||||
|
|
||||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
|
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
|
||||||
|
|
||||||
// SHA256STAMP:85d581977cc3b124df4c81058cab78f13938dfa0cb4845526bb121e396bcf97d
|
// SHA256STAMP:1778bd4f49bef247c2b4789d1f7db3542fd606cbe186e299738aecbfbb2d44ae
|
||||||
|
652
wallet/statements_gettextgen.po
generated
652
wallet/statements_gettextgen.po
generated
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@ ALL_TEST_PROGRAMS += $(WALLET_TEST_PROGRAMS)
|
|||||||
WALLET_TEST_COMMON_OBJS := \
|
WALLET_TEST_COMMON_OBJS := \
|
||||||
common/amount.o \
|
common/amount.o \
|
||||||
common/base32.o \
|
common/base32.o \
|
||||||
|
common/blockheight_states.o \
|
||||||
common/derive_basepoints.o \
|
common/derive_basepoints.o \
|
||||||
common/htlc_state.o \
|
common/htlc_state.o \
|
||||||
common/htlc_wire.o \
|
common/htlc_wire.o \
|
||||||
|
@ -1184,6 +1184,15 @@ static bool channel_inflightseq(struct channel_inflight *i1,
|
|||||||
&i2->last_sig, sizeof(i2->last_sig)));
|
&i2->last_sig, sizeof(i2->last_sig)));
|
||||||
CHECK(bitcoin_tx_eq(i1->last_tx, i2->last_tx));
|
CHECK(bitcoin_tx_eq(i1->last_tx, i2->last_tx));
|
||||||
|
|
||||||
|
CHECK(!i1->lease_commit_sig == !i2->lease_commit_sig);
|
||||||
|
if (i1->lease_commit_sig)
|
||||||
|
CHECK(memeq(i1->lease_commit_sig, sizeof(*i1->lease_commit_sig),
|
||||||
|
i2->lease_commit_sig, sizeof(*i2->lease_commit_sig)));
|
||||||
|
CHECK(i1->lease_expiry == i2->lease_expiry);
|
||||||
|
CHECK(i1->lease_chan_max_msat == i2->lease_chan_max_msat);
|
||||||
|
CHECK(i1->lease_chan_max_ppt == i2->lease_chan_max_ppt);
|
||||||
|
CHECK(i1->lease_blockheight_start == i2->lease_blockheight_start);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1254,6 +1263,27 @@ static bool channelseq(struct channel *c1, struct channel *c2)
|
|||||||
|
|
||||||
CHECK(c1->last_was_revoke == c2->last_was_revoke);
|
CHECK(c1->last_was_revoke == c2->last_was_revoke);
|
||||||
|
|
||||||
|
CHECK(!c1->lease_commit_sig == !c2->lease_commit_sig);
|
||||||
|
if (c1->lease_commit_sig)
|
||||||
|
CHECK(memeq(c1->lease_commit_sig, sizeof(*c1->lease_commit_sig),
|
||||||
|
c2->lease_commit_sig, sizeof(*c2->lease_commit_sig)));
|
||||||
|
|
||||||
|
CHECK(c1->lease_chan_max_msat == c2->lease_chan_max_msat);
|
||||||
|
CHECK(c1->lease_chan_max_ppt == c2->lease_chan_max_ppt);
|
||||||
|
CHECK(c1->lease_expiry == c2->lease_expiry);
|
||||||
|
|
||||||
|
CHECK(height_states_valid(c1->blockheight_states, c1->opener));
|
||||||
|
CHECK(height_states_valid(c2->blockheight_states, c2->opener));
|
||||||
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(c1->blockheight_states->height);
|
||||||
|
i++) {
|
||||||
|
if (c1->blockheight_states->height[i] == NULL) {
|
||||||
|
CHECK(c2->blockheight_states->height[i] == NULL);
|
||||||
|
} else {
|
||||||
|
CHECK(*c1->blockheight_states->height[i]
|
||||||
|
== *c2->blockheight_states->height[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
i1 = list_top(&c1->inflights, struct channel_inflight, list);
|
i1 = list_top(&c1->inflights, struct channel_inflight, list);
|
||||||
i2 = list_top(&c2->inflights, struct channel_inflight, list);
|
i2 = list_top(&c2->inflights, struct channel_inflight, list);
|
||||||
CHECK((i1 != NULL) == (i2 != NULL));
|
CHECK((i1 != NULL) == (i2 != NULL));
|
||||||
@ -1304,7 +1334,7 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
secp256k1_ecdsa_signature *node_sig1 = tal(w, secp256k1_ecdsa_signature);
|
secp256k1_ecdsa_signature *node_sig1 = tal(w, secp256k1_ecdsa_signature);
|
||||||
secp256k1_ecdsa_signature *bitcoin_sig1 = tal(w, secp256k1_ecdsa_signature);
|
secp256k1_ecdsa_signature *bitcoin_sig1 = tal(w, secp256k1_ecdsa_signature);
|
||||||
secp256k1_ecdsa_signature *node_sig2, *bitcoin_sig2;
|
secp256k1_ecdsa_signature *node_sig2, *bitcoin_sig2;
|
||||||
u32 feerate;
|
u32 feerate, blockheight;
|
||||||
bool load;
|
bool load;
|
||||||
|
|
||||||
memset(&c1, 0, sizeof(c1));
|
memset(&c1, 0, sizeof(c1));
|
||||||
@ -1320,6 +1350,8 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
node_id_from_pubkey(&id, &pk);
|
node_id_from_pubkey(&id, &pk);
|
||||||
feerate = 31337;
|
feerate = 31337;
|
||||||
c1.fee_states = new_fee_states(w, c1.opener, &feerate);
|
c1.fee_states = new_fee_states(w, c1.opener, &feerate);
|
||||||
|
blockheight = 10010;
|
||||||
|
c1.blockheight_states = new_height_states(w, c1.opener, &blockheight);
|
||||||
mempat(scriptpubkey, tal_count(scriptpubkey));
|
mempat(scriptpubkey, tal_count(scriptpubkey));
|
||||||
c1.first_blocknum = 1;
|
c1.first_blocknum = 1;
|
||||||
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
|
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
|
||||||
@ -1478,7 +1510,8 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
struct wally_psbt *funding_psbt;
|
struct wally_psbt *funding_psbt;
|
||||||
struct channel_info *channel_info = tal(w, struct channel_info);
|
struct channel_info *channel_info = tal(w, struct channel_info);
|
||||||
struct basepoints basepoints;
|
struct basepoints basepoints;
|
||||||
u32 feerate;
|
secp256k1_ecdsa_signature *lease_commit_sig;
|
||||||
|
u32 feerate, lease_blockheight_start;
|
||||||
u64 dbid;
|
u64 dbid;
|
||||||
|
|
||||||
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
|
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
|
||||||
@ -1493,12 +1526,17 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
our_sats = AMOUNT_SAT(3333333);
|
our_sats = AMOUNT_SAT(3333333);
|
||||||
mempat(&sig.s, sizeof(sig.s));
|
mempat(&sig.s, sizeof(sig.s));
|
||||||
mempat(&cid, sizeof(struct channel_id));
|
mempat(&cid, sizeof(struct channel_id));
|
||||||
|
|
||||||
|
lease_commit_sig = tal(w, secp256k1_ecdsa_signature);
|
||||||
|
mempat(lease_commit_sig, sizeof(*lease_commit_sig));
|
||||||
|
|
||||||
sig.sighash_type = SIGHASH_ALL;
|
sig.sighash_type = SIGHASH_ALL;
|
||||||
|
|
||||||
/* last_tx taken from BOLT #3 */
|
/* last_tx taken from BOLT #3 */
|
||||||
last_tx = bitcoin_tx_from_hex(w, "02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220", strlen("02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220"));
|
last_tx = bitcoin_tx_from_hex(w, "02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220", strlen("02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220"));
|
||||||
funding_psbt = psbt_from_b64(w, "cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA", strlen("cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA"));
|
funding_psbt = psbt_from_b64(w, "cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA", strlen("cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA"));
|
||||||
feerate = 192838;
|
feerate = 192838;
|
||||||
|
lease_blockheight_start = 101010;
|
||||||
memset(&our_config, 1, sizeof(struct channel_config));
|
memset(&our_config, 1, sizeof(struct channel_config));
|
||||||
our_config.id = 0;
|
our_config.id = 0;
|
||||||
memset(&txid, 1, sizeof(txid));
|
memset(&txid, 1, sizeof(txid));
|
||||||
@ -1541,8 +1579,12 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
&pk, NULL,
|
&pk, NULL,
|
||||||
1000, 100,
|
1000, 100,
|
||||||
NULL, 0, 0, true,
|
NULL, 0, 0, true,
|
||||||
LOCAL, REASON_UNKNOWN, NULL,
|
LOCAL, REASON_UNKNOWN,
|
||||||
100, NULL,
|
NULL,
|
||||||
|
new_height_states(w, LOCAL,
|
||||||
|
&lease_blockheight_start),
|
||||||
|
100,
|
||||||
|
lease_commit_sig,
|
||||||
7777, 22);
|
7777, 22);
|
||||||
db_begin_transaction(w->db);
|
db_begin_transaction(w->db);
|
||||||
CHECK(!wallet_err);
|
CHECK(!wallet_err);
|
||||||
@ -1560,7 +1602,7 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
funding_psbt,
|
funding_psbt,
|
||||||
last_tx,
|
last_tx,
|
||||||
sig,
|
sig,
|
||||||
1, NULL, 2, 4);
|
1, lease_commit_sig, 2, 4, 22);
|
||||||
|
|
||||||
/* do inflights get correctly added to the channel? */
|
/* do inflights get correctly added to the channel? */
|
||||||
wallet_inflight_add(w, inflight);
|
wallet_inflight_add(w, inflight);
|
||||||
@ -1582,12 +1624,13 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|||||||
funding_psbt,
|
funding_psbt,
|
||||||
last_tx,
|
last_tx,
|
||||||
sig,
|
sig,
|
||||||
1, NULL, 2, 4);
|
0, NULL, 0, 0, 0);
|
||||||
wallet_inflight_add(w, inflight);
|
wallet_inflight_add(w, inflight);
|
||||||
CHECK_MSG(c2 = wallet_channel_load(w, chan->dbid),
|
CHECK_MSG(c2 = wallet_channel_load(w, chan->dbid),
|
||||||
tal_fmt(w, "Load from DB"));
|
tal_fmt(w, "Load from DB"));
|
||||||
CHECK_MSG(channelseq(chan, c2), "Compare loaded with saved (v2)");
|
CHECK_MSG(channelseq(chan, c2), "Compare loaded with saved (v2)");
|
||||||
CHECK_MSG(count_inflights(w, chan->dbid) == 2, "inflights exist");
|
CHECK_MSG(count_inflights(w, chan->dbid) == 2, "inflights exist");
|
||||||
|
|
||||||
tal_free(c2);
|
tal_free(c2);
|
||||||
|
|
||||||
/* Update the PSBT for both inflights, check that are updated
|
/* Update the PSBT for both inflights, check that are updated
|
||||||
|
120
wallet/wallet.c
120
wallet/wallet.c
@ -6,6 +6,7 @@
|
|||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/blockheight_states.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
#include <common/key_derive.h>
|
#include <common/key_derive.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
@ -966,21 +967,63 @@ static struct fee_states *wallet_channel_fee_states_load(struct wallet *w,
|
|||||||
return fee_states;
|
return fee_states;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct height_states *wallet_channel_height_states_load(struct wallet *w,
|
||||||
|
const u64 id,
|
||||||
|
enum side opener)
|
||||||
|
{
|
||||||
|
struct height_states *states;
|
||||||
|
struct db_stmt *stmt;
|
||||||
|
|
||||||
|
stmt = db_prepare_v2(w->db, SQL("SELECT hstate, blockheight FROM channel_blockheights WHERE channel_id = ?"));
|
||||||
|
db_bind_u64(stmt, 0, id);
|
||||||
|
db_query_prepared(stmt);
|
||||||
|
|
||||||
|
/* Start with blank slate. */
|
||||||
|
states = new_height_states(w, opener, NULL);
|
||||||
|
while (db_step(stmt)) {
|
||||||
|
enum htlc_state hstate = db_column_int(stmt, 0);
|
||||||
|
u32 blockheight = db_column_int(stmt, 1);
|
||||||
|
|
||||||
|
if (states->height[hstate] != NULL) {
|
||||||
|
log_broken(w->log,
|
||||||
|
"duplicate channel_blockheights for %s id %"PRIu64,
|
||||||
|
htlc_state_name(hstate), id);
|
||||||
|
states = tal_free(states);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
states->height[hstate] = tal_dup(states, u32, &blockheight);
|
||||||
|
}
|
||||||
|
tal_free(stmt);
|
||||||
|
|
||||||
|
if (states && !height_states_valid(states, opener)) {
|
||||||
|
log_broken(w->log,
|
||||||
|
"invalid channel_blockheight for id %"PRIu64, id);
|
||||||
|
states = tal_free(states);
|
||||||
|
}
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
void wallet_inflight_add(struct wallet *w, struct channel_inflight *inflight)
|
void wallet_inflight_add(struct wallet *w, struct channel_inflight *inflight)
|
||||||
{
|
{
|
||||||
struct db_stmt *stmt;
|
struct db_stmt *stmt;
|
||||||
stmt = db_prepare_v2(w->db,
|
stmt = db_prepare_v2(w->db,
|
||||||
SQL("INSERT INTO channel_funding_inflights ("
|
SQL("INSERT INTO channel_funding_inflights ("
|
||||||
" channel_id"
|
" channel_id" // 0
|
||||||
", funding_tx_id"
|
", funding_tx_id" // 1
|
||||||
", funding_tx_outnum"
|
", funding_tx_outnum" // 2
|
||||||
", funding_feerate"
|
", funding_feerate" // 3
|
||||||
", funding_satoshi"
|
", funding_satoshi" // 4
|
||||||
", our_funding_satoshi"
|
", our_funding_satoshi" // 5
|
||||||
", funding_psbt"
|
", funding_psbt" // 6
|
||||||
", last_tx"
|
", last_tx" // 7
|
||||||
", last_sig"
|
", last_sig" // 8
|
||||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"));
|
", lease_commit_sig" // 9
|
||||||
|
", lease_chan_max_msat" // 10
|
||||||
|
", lease_chan_max_ppt" // 11
|
||||||
|
", lease_expiry" // 12
|
||||||
|
", lease_blockheight_start" // 13
|
||||||
|
") VALUES ("
|
||||||
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
|
||||||
|
|
||||||
db_bind_u64(stmt, 0, inflight->channel->dbid);
|
db_bind_u64(stmt, 0, inflight->channel->dbid);
|
||||||
db_bind_txid(stmt, 1, &inflight->funding->txid);
|
db_bind_txid(stmt, 1, &inflight->funding->txid);
|
||||||
@ -991,6 +1034,21 @@ void wallet_inflight_add(struct wallet *w, struct channel_inflight *inflight)
|
|||||||
db_bind_psbt(stmt, 6, inflight->funding_psbt);
|
db_bind_psbt(stmt, 6, inflight->funding_psbt);
|
||||||
db_bind_psbt(stmt, 7, inflight->last_tx->psbt);
|
db_bind_psbt(stmt, 7, inflight->last_tx->psbt);
|
||||||
db_bind_signature(stmt, 8, &inflight->last_sig.s);
|
db_bind_signature(stmt, 8, &inflight->last_sig.s);
|
||||||
|
|
||||||
|
if (inflight->lease_expiry != 0) {
|
||||||
|
db_bind_signature(stmt, 9, inflight->lease_commit_sig);
|
||||||
|
db_bind_int(stmt, 10, inflight->lease_chan_max_msat);
|
||||||
|
db_bind_int(stmt, 11, inflight->lease_chan_max_ppt);
|
||||||
|
db_bind_int(stmt, 12, inflight->lease_expiry);
|
||||||
|
db_bind_int(stmt, 13, inflight->lease_blockheight_start);
|
||||||
|
} else {
|
||||||
|
db_bind_null(stmt, 9);
|
||||||
|
db_bind_null(stmt, 10);
|
||||||
|
db_bind_null(stmt, 11);
|
||||||
|
db_bind_int(stmt, 12, 0);
|
||||||
|
db_bind_null(stmt, 13);
|
||||||
|
}
|
||||||
|
|
||||||
db_exec_prepared_v2(stmt);
|
db_exec_prepared_v2(stmt);
|
||||||
assert(!stmt->error);
|
assert(!stmt->error);
|
||||||
tal_free(stmt);
|
tal_free(stmt);
|
||||||
@ -1049,7 +1107,7 @@ wallet_stmt2inflight(struct wallet *w, struct db_stmt *stmt,
|
|||||||
struct channel_inflight *inflight;
|
struct channel_inflight *inflight;
|
||||||
|
|
||||||
secp256k1_ecdsa_signature *lease_commit_sig;
|
secp256k1_ecdsa_signature *lease_commit_sig;
|
||||||
u32 lease_chan_max_msat;
|
u32 lease_chan_max_msat, lease_blockheight_start;
|
||||||
u16 lease_chan_max_ppt;
|
u16 lease_chan_max_ppt;
|
||||||
|
|
||||||
db_column_txid(stmt, 0, &funding_txid);
|
db_column_txid(stmt, 0, &funding_txid);
|
||||||
@ -1065,10 +1123,12 @@ wallet_stmt2inflight(struct wallet *w, struct db_stmt *stmt,
|
|||||||
db_column_signature(stmt, 10, lease_commit_sig);
|
db_column_signature(stmt, 10, lease_commit_sig);
|
||||||
lease_chan_max_msat = db_column_int(stmt, 11);
|
lease_chan_max_msat = db_column_int(stmt, 11);
|
||||||
lease_chan_max_ppt = db_column_int(stmt, 12);
|
lease_chan_max_ppt = db_column_int(stmt, 12);
|
||||||
|
lease_blockheight_start = db_column_int(stmt, 13);
|
||||||
} else {
|
} else {
|
||||||
lease_commit_sig = NULL;
|
lease_commit_sig = NULL;
|
||||||
lease_chan_max_msat = 0;
|
lease_chan_max_msat = 0;
|
||||||
lease_chan_max_ppt = 0;
|
lease_chan_max_ppt = 0;
|
||||||
|
lease_blockheight_start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inflight = new_inflight(chan, funding_txid,
|
inflight = new_inflight(chan, funding_txid,
|
||||||
@ -1082,7 +1142,8 @@ wallet_stmt2inflight(struct wallet *w, struct db_stmt *stmt,
|
|||||||
db_column_int(stmt, 9),
|
db_column_int(stmt, 9),
|
||||||
lease_commit_sig,
|
lease_commit_sig,
|
||||||
lease_chan_max_msat,
|
lease_chan_max_msat,
|
||||||
lease_chan_max_ppt);
|
lease_chan_max_ppt,
|
||||||
|
lease_blockheight_start);
|
||||||
|
|
||||||
/* Pull out the serialized tx-sigs-received-ness */
|
/* Pull out the serialized tx-sigs-received-ness */
|
||||||
inflight->remote_tx_sigs = db_column_int(stmt, 8);
|
inflight->remote_tx_sigs = db_column_int(stmt, 8);
|
||||||
@ -1109,6 +1170,7 @@ static bool wallet_channel_load_inflights(struct wallet *w,
|
|||||||
", lease_commit_sig" // 10
|
", lease_commit_sig" // 10
|
||||||
", lease_chan_max_msat" // 11
|
", lease_chan_max_msat" // 11
|
||||||
", lease_chan_max_ppt" // 12
|
", lease_chan_max_ppt" // 12
|
||||||
|
", lease_blockheight_start" // 13
|
||||||
" FROM channel_funding_inflights"
|
" FROM channel_funding_inflights"
|
||||||
" WHERE channel_id = ?" // ?0
|
" WHERE channel_id = ?" // ?0
|
||||||
" ORDER BY funding_feerate"));
|
" ORDER BY funding_feerate"));
|
||||||
@ -1137,6 +1199,7 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
struct channel_info channel_info;
|
struct channel_info channel_info;
|
||||||
struct fee_states *fee_states;
|
struct fee_states *fee_states;
|
||||||
|
struct height_states *height_states;
|
||||||
struct short_channel_id *scid;
|
struct short_channel_id *scid;
|
||||||
struct channel_id cid;
|
struct channel_id cid;
|
||||||
struct channel *chan;
|
struct channel *chan;
|
||||||
@ -1241,6 +1304,19 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Blockheight states for the channel! */
|
||||||
|
height_states
|
||||||
|
= wallet_channel_height_states_load(w,
|
||||||
|
db_column_u64(stmt, 0),
|
||||||
|
db_column_int(stmt, 7));
|
||||||
|
if (!height_states)
|
||||||
|
ok = false;
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
tal_free(height_states);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
final_key_idx = db_column_u64(stmt, 31);
|
final_key_idx = db_column_u64(stmt, 31);
|
||||||
if (final_key_idx < 0) {
|
if (final_key_idx < 0) {
|
||||||
tal_free(fee_states);
|
tal_free(fee_states);
|
||||||
@ -1330,6 +1406,7 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
|
|||||||
db_column_int(stmt, 51),
|
db_column_int(stmt, 51),
|
||||||
db_column_int(stmt, 52),
|
db_column_int(stmt, 52),
|
||||||
shutdown_wrong_funding,
|
shutdown_wrong_funding,
|
||||||
|
take(height_states),
|
||||||
db_column_int(stmt, 60),
|
db_column_int(stmt, 60),
|
||||||
lease_commit_sig,
|
lease_commit_sig,
|
||||||
lease_chan_max_msat,
|
lease_chan_max_msat,
|
||||||
@ -1833,6 +1910,25 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
|||||||
db_exec_prepared_v2(take(stmt));
|
db_exec_prepared_v2(take(stmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: Updates channel_blockheights by discarding and rewriting. */
|
||||||
|
stmt = db_prepare_v2(w->db, SQL("DELETE FROM channel_blockheights "
|
||||||
|
"WHERE channel_id=?"));
|
||||||
|
db_bind_u64(stmt, 0, chan->dbid);
|
||||||
|
db_exec_prepared_v2(take(stmt));
|
||||||
|
|
||||||
|
for (enum htlc_state i = 0;
|
||||||
|
i < ARRAY_SIZE(chan->blockheight_states->height);
|
||||||
|
i++) {
|
||||||
|
if (!chan->blockheight_states->height[i])
|
||||||
|
continue;
|
||||||
|
stmt = db_prepare_v2(w->db, SQL("INSERT INTO channel_blockheights "
|
||||||
|
" VALUES(?, ?, ?)"));
|
||||||
|
db_bind_u64(stmt, 0, chan->dbid);
|
||||||
|
db_bind_int(stmt, 1, i);
|
||||||
|
db_bind_int(stmt, 2, *chan->blockheight_states->height[i]);
|
||||||
|
db_exec_prepared_v2(take(stmt));
|
||||||
|
}
|
||||||
|
|
||||||
/* If we have a last_sent_commit, store it */
|
/* If we have a last_sent_commit, store it */
|
||||||
last_sent_commit = tal_arr(tmpctx, u8, 0);
|
last_sent_commit = tal_arr(tmpctx, u8, 0);
|
||||||
for (size_t i = 0; i < tal_count(chan->last_sent_commit); i++)
|
for (size_t i = 0; i < tal_count(chan->last_sent_commit); i++)
|
||||||
|
2
wire/bolt12_wiregen.c
generated
2
wire/bolt12_wiregen.c
generated
@ -1684,4 +1684,4 @@ bool invoice_error_is_valid(const struct tlv_invoice_error *record, size_t *err_
|
|||||||
return tlv_fields_valid(record->fields, NULL, err_index);
|
return tlv_fields_valid(record->fields, NULL, err_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHA256STAMP:95d5be81bb0846cff337017b812800a19bf176d3182dd605bfe03086c14ef1f4
|
// SHA256STAMP:27ffc38bc2be76e159508470734655f35e59d82927beb8c1f62917e592d76d10
|
||||||
|
2
wire/bolt12_wiregen.h
generated
2
wire/bolt12_wiregen.h
generated
@ -323,4 +323,4 @@ struct fallback_address *fromwire_fallback_address(const tal_t *ctx, const u8 **
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_WIRE_BOLT12_WIREGEN_H */
|
#endif /* LIGHTNING_WIRE_BOLT12_WIREGEN_H */
|
||||||
// SHA256STAMP:95d5be81bb0846cff337017b812800a19bf176d3182dd605bfe03086c14ef1f4
|
// SHA256STAMP:27ffc38bc2be76e159508470734655f35e59d82927beb8c1f62917e592d76d10
|
||||||
|
2
wire/common_wiregen.c
generated
2
wire/common_wiregen.c
generated
@ -100,4 +100,4 @@ bool fromwire_custommsg_out(const tal_t *ctx, const void *p, u8 **msg)
|
|||||||
fromwire_u8_array(&cursor, &plen, *msg, msg_len);
|
fromwire_u8_array(&cursor, &plen, *msg, msg_len);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:20f78b01d36c7db37e7316d8ab52740dd5f39011ea306f0e8b6a5a4a6bbc7c9e
|
// SHA256STAMP:959a0af7e5dc054bc1bd313dee486b3c2040853b8f3772d889e51048e14ac2b5
|
||||||
|
2
wire/common_wiregen.h
generated
2
wire/common_wiregen.h
generated
@ -41,4 +41,4 @@ bool fromwire_custommsg_out(const tal_t *ctx, const void *p, u8 **msg);
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_WIRE_COMMON_WIREGEN_H */
|
#endif /* LIGHTNING_WIRE_COMMON_WIREGEN_H */
|
||||||
// SHA256STAMP:20f78b01d36c7db37e7316d8ab52740dd5f39011ea306f0e8b6a5a4a6bbc7c9e
|
// SHA256STAMP:959a0af7e5dc054bc1bd313dee486b3c2040853b8f3772d889e51048e14ac2b5
|
||||||
|
2
wire/onion_printgen.c
generated
2
wire/onion_printgen.c
generated
@ -859,4 +859,4 @@ void printonion_wire_tlv_message(const char *tlv_name, const u8 *msg) {
|
|||||||
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_encmsg_tlvs, ARRAY_SIZE(print_tlvs_encmsg_tlvs));
|
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_encmsg_tlvs, ARRAY_SIZE(print_tlvs_encmsg_tlvs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SHA256STAMP:aeab913b5da11a9166e167e47d60cd748aa35a8c6c9adc2a7c1f791bed70797f
|
// SHA256STAMP:fcaea2b057478205299b8935161c994fece0e410e6942503943747625ddcfc8a
|
||||||
|
2
wire/onion_printgen.h
generated
2
wire/onion_printgen.h
generated
@ -58,4 +58,4 @@ void printwire_mpp_timeout(const char *fieldname, const u8 *cursor);
|
|||||||
|
|
||||||
void printwire_onionmsg_path(const char *fieldname, const u8 **cursor, size_t *plen);
|
void printwire_onionmsg_path(const char *fieldname, const u8 **cursor, size_t *plen);
|
||||||
#endif /* LIGHTNING_WIRE_ONION_PRINTGEN_H */
|
#endif /* LIGHTNING_WIRE_ONION_PRINTGEN_H */
|
||||||
// SHA256STAMP:aeab913b5da11a9166e167e47d60cd748aa35a8c6c9adc2a7c1f791bed70797f
|
// SHA256STAMP:fcaea2b057478205299b8935161c994fece0e410e6942503943747625ddcfc8a
|
||||||
|
2
wire/onion_wiregen.c
generated
2
wire/onion_wiregen.c
generated
@ -1026,4 +1026,4 @@ bool fromwire_mpp_timeout(const void *p)
|
|||||||
return false;
|
return false;
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:aeab913b5da11a9166e167e47d60cd748aa35a8c6c9adc2a7c1f791bed70797f
|
// SHA256STAMP:fcaea2b057478205299b8935161c994fece0e410e6942503943747625ddcfc8a
|
||||||
|
2
wire/onion_wiregen.h
generated
2
wire/onion_wiregen.h
generated
@ -317,4 +317,4 @@ bool fromwire_mpp_timeout(const void *p);
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_WIRE_ONION_WIREGEN_H */
|
#endif /* LIGHTNING_WIRE_ONION_WIREGEN_H */
|
||||||
// SHA256STAMP:aeab913b5da11a9166e167e47d60cd748aa35a8c6c9adc2a7c1f791bed70797f
|
// SHA256STAMP:fcaea2b057478205299b8935161c994fece0e410e6942503943747625ddcfc8a
|
||||||
|
2
wire/peer_printgen.c
generated
2
wire/peer_printgen.c
generated
@ -3079,4 +3079,4 @@ void printpeer_wire_tlv_message(const char *tlv_name, const u8 *msg) {
|
|||||||
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_onion_message_tlvs, ARRAY_SIZE(print_tlvs_onion_message_tlvs));
|
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_onion_message_tlvs, ARRAY_SIZE(print_tlvs_onion_message_tlvs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SHA256STAMP:4751c4834d5db7d170f8e1ee40ea8b5e12b5552780d37b099fe5fae6f0342c9e
|
// SHA256STAMP:7c9612ec7cc62b3a44ae65d19b855b521e96796940b4c3d50977d768ace8712e
|
||||||
|
2
wire/peer_printgen.h
generated
2
wire/peer_printgen.h
generated
@ -99,4 +99,4 @@ void printwire_channel_update_checksums(const char *fieldname, const u8 **cursor
|
|||||||
void printwire_channel_update_timestamps(const char *fieldname, const u8 **cursor, size_t *plen);
|
void printwire_channel_update_timestamps(const char *fieldname, const u8 **cursor, size_t *plen);
|
||||||
void printwire_witness_stack(const char *fieldname, const u8 **cursor, size_t *plen);
|
void printwire_witness_stack(const char *fieldname, const u8 **cursor, size_t *plen);
|
||||||
#endif /* LIGHTNING_WIRE_PEER_PRINTGEN_H */
|
#endif /* LIGHTNING_WIRE_PEER_PRINTGEN_H */
|
||||||
// SHA256STAMP:4751c4834d5db7d170f8e1ee40ea8b5e12b5552780d37b099fe5fae6f0342c9e
|
// SHA256STAMP:7c9612ec7cc62b3a44ae65d19b855b521e96796940b4c3d50977d768ace8712e
|
||||||
|
2
wire/peer_wiregen.c
generated
2
wire/peer_wiregen.c
generated
@ -2484,4 +2484,4 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ec
|
|||||||
*htlc_maximum_msat = fromwire_amount_msat(&cursor, &plen);
|
*htlc_maximum_msat = fromwire_amount_msat(&cursor, &plen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:4751c4834d5db7d170f8e1ee40ea8b5e12b5552780d37b099fe5fae6f0342c9e
|
// SHA256STAMP:7c9612ec7cc62b3a44ae65d19b855b521e96796940b4c3d50977d768ace8712e
|
||||||
|
2
wire/peer_wiregen.h
generated
2
wire/peer_wiregen.h
generated
@ -930,4 +930,4 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ec
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_WIRE_PEER_WIREGEN_H */
|
#endif /* LIGHTNING_WIRE_PEER_WIREGEN_H */
|
||||||
// SHA256STAMP:4751c4834d5db7d170f8e1ee40ea8b5e12b5552780d37b099fe5fae6f0342c9e
|
// SHA256STAMP:7c9612ec7cc62b3a44ae65d19b855b521e96796940b4c3d50977d768ace8712e
|
||||||
|
Loading…
Reference in New Issue
Block a user