channel: wire blockheight updates from channeld in to database

This commit is contained in:
niftynei 2021-06-22 16:47:33 -05:00 committed by neil saitug
parent 265f960cfe
commit 67b8a22aa7
12 changed files with 79 additions and 31 deletions

View File

@ -927,6 +927,7 @@ static u8 *sending_commitsig_msg(const tal_t *ctx,
u64 remote_commit_index, u64 remote_commit_index,
struct penalty_base *pbase, struct penalty_base *pbase,
const struct fee_states *fee_states, const struct fee_states *fee_states,
const struct height_states *blockheight_states,
const struct htlc **changed_htlcs, const struct htlc **changed_htlcs,
const struct bitcoin_signature *commit_sig, const struct bitcoin_signature *commit_sig,
const struct bitcoin_signature *htlc_sigs) const struct bitcoin_signature *htlc_sigs)
@ -937,8 +938,10 @@ static u8 *sending_commitsig_msg(const tal_t *ctx,
/* We tell master what (of our) HTLCs peer will now be /* We tell master what (of our) HTLCs peer will now be
* committed to. */ * committed to. */
changed = changed_htlc_arr(tmpctx, changed_htlcs); changed = changed_htlc_arr(tmpctx, changed_htlcs);
msg = towire_channeld_sending_commitsig(ctx, remote_commit_index, pbase, fee_states, changed, msg = towire_channeld_sending_commitsig(ctx, remote_commit_index,
commit_sig, htlc_sigs); pbase, fee_states,
blockheight_states, changed,
commit_sig, htlc_sigs);
return msg; return msg;
} }
@ -1388,6 +1391,7 @@ static void send_commit(struct peer *peer)
msg = sending_commitsig_msg(NULL, peer->next_index[REMOTE], msg = sending_commitsig_msg(NULL, peer->next_index[REMOTE],
pbase, pbase,
peer->channel->fee_states, peer->channel->fee_states,
peer->channel->blockheight_states,
changed_htlcs, changed_htlcs,
&commit_sig, &commit_sig,
htlc_sigs); htlc_sigs);
@ -1562,6 +1566,7 @@ static void send_revocation(struct peer *peer,
= towire_channeld_got_commitsig(NULL, = towire_channeld_got_commitsig(NULL,
peer->next_index[LOCAL] - 1, peer->next_index[LOCAL] - 1,
peer->channel->fee_states, peer->channel->fee_states,
peer->channel->blockheight_states,
commit_sig, htlc_sigs, commit_sig, htlc_sigs,
added, added,
fulfilled, fulfilled,
@ -1740,7 +1745,8 @@ static u8 *got_revoke_msg(struct peer *peer, u64 revoke_num,
const struct secret *per_commitment_secret, const struct secret *per_commitment_secret,
const struct pubkey *next_per_commit_point, const struct pubkey *next_per_commit_point,
const struct htlc **changed_htlcs, const struct htlc **changed_htlcs,
const struct fee_states *fee_states) const struct fee_states *fee_states,
const struct height_states *blockheight_states)
{ {
u8 *msg; u8 *msg;
struct penalty_base *pbase; struct penalty_base *pbase;
@ -1772,7 +1778,8 @@ static u8 *got_revoke_msg(struct peer *peer, u64 revoke_num,
msg = towire_channeld_got_revoke(peer, revoke_num, per_commitment_secret, msg = towire_channeld_got_revoke(peer, revoke_num, per_commitment_secret,
next_per_commit_point, fee_states, next_per_commit_point, fee_states,
changed, pbase, ptx); blockheight_states, changed,
pbase, ptx);
tal_free(ptx); tal_free(ptx);
return msg; return msg;
} }
@ -1829,7 +1836,8 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
msg = got_revoke_msg(peer, peer->revocations_received++, msg = got_revoke_msg(peer, peer->revocations_received++,
&old_commit_secret, &next_per_commit, &old_commit_secret, &next_per_commit,
changed_htlcs, changed_htlcs,
peer->channel->fee_states); peer->channel->fee_states,
peer->channel->blockheight_states);
master_wait_sync_reply(tmpctx, peer, take(msg), master_wait_sync_reply(tmpctx, peer, take(msg),
WIRE_CHANNELD_GOT_REVOKE_REPLY); WIRE_CHANNELD_GOT_REVOKE_REPLY);

View File

@ -121,6 +121,7 @@ msgtype,channeld_sending_commitsig,1020
msgdata,channeld_sending_commitsig,commitnum,u64, msgdata,channeld_sending_commitsig,commitnum,u64,
msgdata,channeld_sending_commitsig,pbase,?penalty_base, msgdata,channeld_sending_commitsig,pbase,?penalty_base,
msgdata,channeld_sending_commitsig,fee_states,fee_states, msgdata,channeld_sending_commitsig,fee_states,fee_states,
msgdata,channeld_sending_commitsig,blockheight_states,height_states,
# SENT_ADD_COMMIT, SENT_REMOVE_ACK_COMMIT, SENT_ADD_ACK_COMMIT, SENT_REMOVE_COMMIT # SENT_ADD_COMMIT, SENT_REMOVE_ACK_COMMIT, SENT_ADD_ACK_COMMIT, SENT_REMOVE_COMMIT
msgdata,channeld_sending_commitsig,num_changed,u16, msgdata,channeld_sending_commitsig,num_changed,u16,
msgdata,channeld_sending_commitsig,changed,changed_htlc,num_changed msgdata,channeld_sending_commitsig,changed,changed_htlc,num_changed
@ -135,6 +136,7 @@ msgtype,channeld_sending_commitsig_reply,1120
msgtype,channeld_got_commitsig,1021 msgtype,channeld_got_commitsig,1021
msgdata,channeld_got_commitsig,commitnum,u64, msgdata,channeld_got_commitsig,commitnum,u64,
msgdata,channeld_got_commitsig,fee_states,fee_states, msgdata,channeld_got_commitsig,fee_states,fee_states,
msgdata,channeld_got_commitsig,blockheight_states,height_states,
msgdata,channeld_got_commitsig,signature,bitcoin_signature, msgdata,channeld_got_commitsig,signature,bitcoin_signature,
msgdata,channeld_got_commitsig,num_htlcs,u16, msgdata,channeld_got_commitsig,num_htlcs,u16,
msgdata,channeld_got_commitsig,htlc_signature,bitcoin_signature,num_htlcs msgdata,channeld_got_commitsig,htlc_signature,bitcoin_signature,num_htlcs
@ -162,6 +164,7 @@ msgdata,channeld_got_revoke,per_commitment_secret,secret,
msgdata,channeld_got_revoke,next_per_commit_point,pubkey, msgdata,channeld_got_revoke,next_per_commit_point,pubkey,
# RCVD_ADD_ACK_REVOCATION, RCVD_REMOVE_ACK_REVOCATION, RCVD_ADD_REVOCATION, RCVD_REMOVE_REVOCATION # RCVD_ADD_ACK_REVOCATION, RCVD_REMOVE_ACK_REVOCATION, RCVD_ADD_REVOCATION, RCVD_REMOVE_REVOCATION
msgdata,channeld_got_revoke,fee_states,fee_states, msgdata,channeld_got_revoke,fee_states,fee_states,
msgdata,channeld_got_revoke,blockheight_states,height_states,
msgdata,channeld_got_revoke,num_changed,u16, msgdata,channeld_got_revoke,num_changed,u16,
msgdata,channeld_got_revoke,changed,changed_htlc,num_changed msgdata,channeld_got_revoke,changed,changed_htlc,num_changed
msgdata,channeld_got_revoke,pbase,?penalty_base, msgdata,channeld_got_revoke,pbase,?penalty_base,

Can't render this file because it has a wrong number of fields in line 13.

View File

@ -490,7 +490,7 @@ bool fromwire_channeld_got_funding_locked(const void *p, struct pubkey *next_per
/* WIRE: CHANNELD_SENDING_COMMITSIG */ /* WIRE: CHANNELD_SENDING_COMMITSIG */
/* When we send a commitment_signed message */ /* When we send a commitment_signed message */
u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const struct penalty_base *pbase, const struct fee_states *fee_states, const struct changed_htlc *changed, const struct bitcoin_signature *commit_sig, const struct bitcoin_signature *htlc_sigs) u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const struct penalty_base *pbase, const struct fee_states *fee_states, const struct height_states *blockheight_states, const struct changed_htlc *changed, const struct bitcoin_signature *commit_sig, const struct bitcoin_signature *htlc_sigs)
{ {
u16 num_changed = tal_count(changed); u16 num_changed = tal_count(changed);
u16 num_htlc_sigs = tal_count(htlc_sigs); u16 num_htlc_sigs = tal_count(htlc_sigs);
@ -505,6 +505,7 @@ u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const str
towire_penalty_base(&p, pbase); towire_penalty_base(&p, pbase);
} }
towire_fee_states(&p, fee_states); towire_fee_states(&p, fee_states);
towire_height_states(&p, blockheight_states);
/* SENT_ADD_COMMIT */ /* SENT_ADD_COMMIT */
towire_u16(&p, num_changed); towire_u16(&p, num_changed);
for (size_t i = 0; i < num_changed; i++) for (size_t i = 0; i < num_changed; i++)
@ -516,7 +517,7 @@ u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const str
return memcheck(p, tal_count(p)); return memcheck(p, tal_count(p));
} }
bool fromwire_channeld_sending_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct penalty_base **pbase, struct fee_states **fee_states, struct changed_htlc **changed, struct bitcoin_signature *commit_sig, struct bitcoin_signature **htlc_sigs) bool fromwire_channeld_sending_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct penalty_base **pbase, struct fee_states **fee_states, struct height_states **blockheight_states, struct changed_htlc **changed, struct bitcoin_signature *commit_sig, struct bitcoin_signature **htlc_sigs)
{ {
u16 num_changed; u16 num_changed;
u16 num_htlc_sigs; u16 num_htlc_sigs;
@ -534,6 +535,7 @@ bool fromwire_channeld_sending_commitsig(const tal_t *ctx, const void *p, u64 *c
fromwire_penalty_base(&cursor, &plen, *pbase); fromwire_penalty_base(&cursor, &plen, *pbase);
} }
*fee_states = fromwire_fee_states(ctx, &cursor, &plen); *fee_states = fromwire_fee_states(ctx, &cursor, &plen);
*blockheight_states = fromwire_height_states(ctx, &cursor, &plen);
/* SENT_ADD_COMMIT */ /* SENT_ADD_COMMIT */
num_changed = fromwire_u16(&cursor, &plen); num_changed = fromwire_u16(&cursor, &plen);
// 2nd case changed // 2nd case changed
@ -571,7 +573,7 @@ bool fromwire_channeld_sending_commitsig_reply(const void *p)
/* WIRE: CHANNELD_GOT_COMMITSIG */ /* WIRE: CHANNELD_GOT_COMMITSIG */
/* When we have a commitment_signed message */ /* When we have a commitment_signed message */
u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct fee_states *fee_states, const struct bitcoin_signature *signature, const struct bitcoin_signature *htlc_signature, const struct added_htlc *added, const struct fulfilled_htlc *fulfilled, const struct failed_htlc **failed, const struct changed_htlc *changed, const struct bitcoin_tx *tx) u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct fee_states *fee_states, const struct height_states *blockheight_states, const struct bitcoin_signature *signature, const struct bitcoin_signature *htlc_signature, const struct added_htlc *added, const struct fulfilled_htlc *fulfilled, const struct failed_htlc **failed, const struct changed_htlc *changed, const struct bitcoin_tx *tx)
{ {
u16 num_htlcs = tal_count(htlc_signature); u16 num_htlcs = tal_count(htlc_signature);
u16 num_added = tal_count(added); u16 num_added = tal_count(added);
@ -583,6 +585,7 @@ u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct
towire_u16(&p, WIRE_CHANNELD_GOT_COMMITSIG); towire_u16(&p, WIRE_CHANNELD_GOT_COMMITSIG);
towire_u64(&p, commitnum); towire_u64(&p, commitnum);
towire_fee_states(&p, fee_states); towire_fee_states(&p, fee_states);
towire_height_states(&p, blockheight_states);
towire_bitcoin_signature(&p, signature); towire_bitcoin_signature(&p, signature);
towire_u16(&p, num_htlcs); towire_u16(&p, num_htlcs);
for (size_t i = 0; i < num_htlcs; i++) for (size_t i = 0; i < num_htlcs; i++)
@ -606,7 +609,7 @@ u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct
return memcheck(p, tal_count(p)); return memcheck(p, tal_count(p));
} }
bool fromwire_channeld_got_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct fee_states **fee_states, struct bitcoin_signature *signature, struct bitcoin_signature **htlc_signature, struct added_htlc **added, struct fulfilled_htlc **fulfilled, struct failed_htlc ***failed, struct changed_htlc **changed, struct bitcoin_tx **tx) bool fromwire_channeld_got_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct fee_states **fee_states, struct height_states **blockheight_states, struct bitcoin_signature *signature, struct bitcoin_signature **htlc_signature, struct added_htlc **added, struct fulfilled_htlc **fulfilled, struct failed_htlc ***failed, struct changed_htlc **changed, struct bitcoin_tx **tx)
{ {
u16 num_htlcs; u16 num_htlcs;
u16 num_added; u16 num_added;
@ -621,6 +624,7 @@ bool fromwire_channeld_got_commitsig(const tal_t *ctx, const void *p, u64 *commi
return false; return false;
*commitnum = fromwire_u64(&cursor, &plen); *commitnum = fromwire_u64(&cursor, &plen);
*fee_states = fromwire_fee_states(ctx, &cursor, &plen); *fee_states = fromwire_fee_states(ctx, &cursor, &plen);
*blockheight_states = fromwire_height_states(ctx, &cursor, &plen);
fromwire_bitcoin_signature(&cursor, &plen, signature); fromwire_bitcoin_signature(&cursor, &plen, signature);
num_htlcs = fromwire_u16(&cursor, &plen); num_htlcs = fromwire_u16(&cursor, &plen);
// 2nd case htlc_signature // 2nd case htlc_signature
@ -675,7 +679,7 @@ bool fromwire_channeld_got_commitsig_reply(const void *p)
} }
/* WIRE: CHANNELD_GOT_REVOKE */ /* WIRE: CHANNELD_GOT_REVOKE */
u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct secret *per_commitment_secret, const struct pubkey *next_per_commit_point, const struct fee_states *fee_states, const struct changed_htlc *changed, const struct penalty_base *pbase, const struct bitcoin_tx *penalty_tx) u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct secret *per_commitment_secret, const struct pubkey *next_per_commit_point, const struct fee_states *fee_states, const struct height_states *blockheight_states, const struct changed_htlc *changed, const struct penalty_base *pbase, const struct bitcoin_tx *penalty_tx)
{ {
u16 num_changed = tal_count(changed); u16 num_changed = tal_count(changed);
u8 *p = tal_arr(ctx, u8, 0); u8 *p = tal_arr(ctx, u8, 0);
@ -686,6 +690,7 @@ u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct sec
towire_pubkey(&p, next_per_commit_point); towire_pubkey(&p, next_per_commit_point);
/* RCVD_ADD_ACK_REVOCATION */ /* RCVD_ADD_ACK_REVOCATION */
towire_fee_states(&p, fee_states); towire_fee_states(&p, fee_states);
towire_height_states(&p, blockheight_states);
towire_u16(&p, num_changed); towire_u16(&p, num_changed);
for (size_t i = 0; i < num_changed; i++) for (size_t i = 0; i < num_changed; i++)
towire_changed_htlc(&p, changed + i); towire_changed_htlc(&p, changed + i);
@ -704,7 +709,7 @@ u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct sec
return memcheck(p, tal_count(p)); return memcheck(p, tal_count(p));
} }
bool fromwire_channeld_got_revoke(const tal_t *ctx, const void *p, u64 *revokenum, struct secret *per_commitment_secret, struct pubkey *next_per_commit_point, struct fee_states **fee_states, struct changed_htlc **changed, struct penalty_base **pbase, struct bitcoin_tx **penalty_tx) bool fromwire_channeld_got_revoke(const tal_t *ctx, const void *p, u64 *revokenum, struct secret *per_commitment_secret, struct pubkey *next_per_commit_point, struct fee_states **fee_states, struct height_states **blockheight_states, struct changed_htlc **changed, struct penalty_base **pbase, struct bitcoin_tx **penalty_tx)
{ {
u16 num_changed; u16 num_changed;
@ -718,6 +723,7 @@ bool fromwire_channeld_got_revoke(const tal_t *ctx, const void *p, u64 *revokenu
fromwire_pubkey(&cursor, &plen, next_per_commit_point); fromwire_pubkey(&cursor, &plen, next_per_commit_point);
/* RCVD_ADD_ACK_REVOCATION */ /* RCVD_ADD_ACK_REVOCATION */
*fee_states = fromwire_fee_states(ctx, &cursor, &plen); *fee_states = fromwire_fee_states(ctx, &cursor, &plen);
*blockheight_states = fromwire_height_states(ctx, &cursor, &plen);
num_changed = fromwire_u16(&cursor, &plen); num_changed = fromwire_u16(&cursor, &plen);
// 2nd case changed // 2nd case changed
*changed = num_changed ? tal_arr(ctx, struct changed_htlc, num_changed) : NULL; *changed = num_changed ? tal_arr(ctx, struct changed_htlc, num_changed) : NULL;
@ -1175,4 +1181,4 @@ bool fromwire_channeld_blockheight(const void *p, u32 *blockheight)
*blockheight = fromwire_u32(&cursor, &plen); *blockheight = fromwire_u32(&cursor, &plen);
return cursor != NULL; return cursor != NULL;
} }
// SHA256STAMP:40a8d4ea75d57eeddfb5cc648a9ca3e3914dfe500a6054b6a6942f4023a17d82 // SHA256STAMP:977cf1dac7bbca4163cfbbf53f8f448430775368496205ee6f181eb4d8c8c8af

View File

@ -129,8 +129,8 @@ bool fromwire_channeld_got_funding_locked(const void *p, struct pubkey *next_per
/* WIRE: CHANNELD_SENDING_COMMITSIG */ /* WIRE: CHANNELD_SENDING_COMMITSIG */
/* When we send a commitment_signed message */ /* When we send a commitment_signed message */
u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const struct penalty_base *pbase, const struct fee_states *fee_states, const struct changed_htlc *changed, const struct bitcoin_signature *commit_sig, const struct bitcoin_signature *htlc_sigs); u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const struct penalty_base *pbase, const struct fee_states *fee_states, const struct height_states *blockheight_states, const struct changed_htlc *changed, const struct bitcoin_signature *commit_sig, const struct bitcoin_signature *htlc_sigs);
bool fromwire_channeld_sending_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct penalty_base **pbase, struct fee_states **fee_states, struct changed_htlc **changed, struct bitcoin_signature *commit_sig, struct bitcoin_signature **htlc_sigs); bool fromwire_channeld_sending_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct penalty_base **pbase, struct fee_states **fee_states, struct height_states **blockheight_states, struct changed_htlc **changed, struct bitcoin_signature *commit_sig, struct bitcoin_signature **htlc_sigs);
/* WIRE: CHANNELD_SENDING_COMMITSIG_REPLY */ /* WIRE: CHANNELD_SENDING_COMMITSIG_REPLY */
/* Wait for reply */ /* Wait for reply */
@ -139,8 +139,8 @@ bool fromwire_channeld_sending_commitsig_reply(const void *p);
/* WIRE: CHANNELD_GOT_COMMITSIG */ /* WIRE: CHANNELD_GOT_COMMITSIG */
/* When we have a commitment_signed message */ /* When we have a commitment_signed message */
u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct fee_states *fee_states, const struct bitcoin_signature *signature, const struct bitcoin_signature *htlc_signature, const struct added_htlc *added, const struct fulfilled_htlc *fulfilled, const struct failed_htlc **failed, const struct changed_htlc *changed, const struct bitcoin_tx *tx); u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct fee_states *fee_states, const struct height_states *blockheight_states, const struct bitcoin_signature *signature, const struct bitcoin_signature *htlc_signature, const struct added_htlc *added, const struct fulfilled_htlc *fulfilled, const struct failed_htlc **failed, const struct changed_htlc *changed, const struct bitcoin_tx *tx);
bool fromwire_channeld_got_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct fee_states **fee_states, struct bitcoin_signature *signature, struct bitcoin_signature **htlc_signature, struct added_htlc **added, struct fulfilled_htlc **fulfilled, struct failed_htlc ***failed, struct changed_htlc **changed, struct bitcoin_tx **tx); bool fromwire_channeld_got_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct fee_states **fee_states, struct height_states **blockheight_states, struct bitcoin_signature *signature, struct bitcoin_signature **htlc_signature, struct added_htlc **added, struct fulfilled_htlc **fulfilled, struct failed_htlc ***failed, struct changed_htlc **changed, struct bitcoin_tx **tx);
/* WIRE: CHANNELD_GOT_COMMITSIG_REPLY */ /* WIRE: CHANNELD_GOT_COMMITSIG_REPLY */
/* Wait for reply */ /* Wait for reply */
@ -148,8 +148,8 @@ u8 *towire_channeld_got_commitsig_reply(const tal_t *ctx);
bool fromwire_channeld_got_commitsig_reply(const void *p); bool fromwire_channeld_got_commitsig_reply(const void *p);
/* WIRE: CHANNELD_GOT_REVOKE */ /* WIRE: CHANNELD_GOT_REVOKE */
u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct secret *per_commitment_secret, const struct pubkey *next_per_commit_point, const struct fee_states *fee_states, const struct changed_htlc *changed, const struct penalty_base *pbase, const struct bitcoin_tx *penalty_tx); u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct secret *per_commitment_secret, const struct pubkey *next_per_commit_point, const struct fee_states *fee_states, const struct height_states *blockheight_states, const struct changed_htlc *changed, const struct penalty_base *pbase, const struct bitcoin_tx *penalty_tx);
bool fromwire_channeld_got_revoke(const tal_t *ctx, const void *p, u64 *revokenum, struct secret *per_commitment_secret, struct pubkey *next_per_commit_point, struct fee_states **fee_states, struct changed_htlc **changed, struct penalty_base **pbase, struct bitcoin_tx **penalty_tx); bool fromwire_channeld_got_revoke(const tal_t *ctx, const void *p, u64 *revokenum, struct secret *per_commitment_secret, struct pubkey *next_per_commit_point, struct fee_states **fee_states, struct height_states **blockheight_states, struct changed_htlc **changed, struct penalty_base **pbase, struct bitcoin_tx **penalty_tx);
/* WIRE: CHANNELD_GOT_REVOKE_REPLY */ /* WIRE: CHANNELD_GOT_REVOKE_REPLY */
/* Wait for reply */ /* Wait for reply */
@ -240,4 +240,4 @@ bool fromwire_channeld_blockheight(const void *p, u32 *blockheight);
#endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */ #endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */
// SHA256STAMP:40a8d4ea75d57eeddfb5cc648a9ca3e3914dfe500a6054b6a6942f4023a17d82 // SHA256STAMP:977cf1dac7bbca4163cfbbf53f8f448430775368496205ee6f181eb4d8c8c8af

View File

@ -161,6 +161,12 @@ u32 channel_feerate(const struct channel *channel, enum side side)
return get_feerate(channel->fee_states, channel->opener, side); return get_feerate(channel->fee_states, channel->opener, side);
} }
u32 channel_blockheight(const struct channel *channel, enum side side)
{
return get_blockheight(channel->blockheight_states,
channel->opener, side);
}
#if EXPERIMENTAL_FEATURES #if EXPERIMENTAL_FEATURES
/* BOLT-upgrade_protocol #2: /* BOLT-upgrade_protocol #2:
* Channel features are explicitly enumerated as `channel_type` bitfields, * Channel features are explicitly enumerated as `channel_type` bitfields,

View File

@ -151,6 +151,13 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
*/ */
u32 channel_feerate(const struct channel *channel, enum side side); u32 channel_feerate(const struct channel *channel, enum side side);
/**
* channel_blockheight: Get blockheight for this side of channel.
* @channel: The channel
* @side: the side
*/
u32 channel_blockheight(const struct channel *channel, enum side side);
#if EXPERIMENTAL_FEATURES #if EXPERIMENTAL_FEATURES
/* BOLT-upgrade_protocol #2: /* BOLT-upgrade_protocol #2:
* Channel features are explicitly enumerated as `channel_type` bitfields, * Channel features are explicitly enumerated as `channel_type` bitfields,

View File

@ -1736,6 +1736,7 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg)
{ {
u64 commitnum; u64 commitnum;
struct fee_states *fee_states; struct fee_states *fee_states;
struct height_states *blockheight_states;
struct changed_htlc *changed_htlcs; struct changed_htlc *changed_htlcs;
size_t i, maxid = 0, num_local_added = 0; size_t i, maxid = 0, num_local_added = 0;
struct bitcoin_signature commit_sig; struct bitcoin_signature commit_sig;
@ -1747,9 +1748,11 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg)
&commitnum, &commitnum,
&pbase, &pbase,
&fee_states, &fee_states,
&blockheight_states,
&changed_htlcs, &changed_htlcs,
&commit_sig, &htlc_sigs) &commit_sig, &htlc_sigs)
|| !fee_states_valid(fee_states, channel->opener)) { || !fee_states_valid(fee_states, channel->opener)
|| !height_states_valid(blockheight_states, channel->opener)) {
channel_internal_error(channel, "bad channel_sending_commitsig %s", channel_internal_error(channel, "bad channel_sending_commitsig %s",
tal_hex(channel, msg)); tal_hex(channel, msg));
return; return;
@ -1792,6 +1795,9 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg)
channel->opener, channel->opener,
REMOTE)); REMOTE));
tal_free(channel->blockheight_states);
channel->blockheight_states = tal_steal(channel, blockheight_states);
if (!peer_save_commitsig_sent(channel, commitnum)) if (!peer_save_commitsig_sent(channel, commitnum))
return; return;
@ -1927,6 +1933,7 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg)
{ {
u64 commitnum; u64 commitnum;
struct fee_states *fee_states; struct fee_states *fee_states;
struct height_states *blockheight_states;
struct bitcoin_signature commit_sig, *htlc_sigs; struct bitcoin_signature commit_sig, *htlc_sigs;
struct added_htlc *added; struct added_htlc *added;
struct fulfilled_htlc *fulfilled; struct fulfilled_htlc *fulfilled;
@ -1939,6 +1946,7 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg)
if (!fromwire_channeld_got_commitsig(msg, msg, if (!fromwire_channeld_got_commitsig(msg, msg,
&commitnum, &commitnum,
&fee_states, &fee_states,
&blockheight_states,
&commit_sig, &commit_sig,
&htlc_sigs, &htlc_sigs,
&added, &added,
@ -1946,7 +1954,8 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg)
&failed, &failed,
&changed, &changed,
&tx) &tx)
|| !fee_states_valid(fee_states, channel->opener)) { || !fee_states_valid(fee_states, channel->opener)
|| !height_states_valid(blockheight_states, channel->opener)) {
channel_internal_error(channel, channel_internal_error(channel,
"bad fromwire_channeld_got_commitsig %s", "bad fromwire_channeld_got_commitsig %s",
tal_hex(channel, msg)); tal_hex(channel, msg));
@ -1975,8 +1984,9 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg)
log_debug(channel->log, log_debug(channel->log,
"got commitsig %"PRIu64 "got commitsig %"PRIu64
": feerate %u, %zu added, %zu fulfilled, %zu failed, %zu changed", ": feerate %u, blockheight: %u, %zu added, %zu fulfilled, %zu failed, %zu changed",
commitnum, get_feerate(fee_states, channel->opener, LOCAL), commitnum, get_feerate(fee_states, channel->opener, LOCAL),
get_blockheight(blockheight_states, channel->opener, LOCAL),
tal_count(added), tal_count(fulfilled), tal_count(added), tal_count(fulfilled),
tal_count(failed), tal_count(changed)); tal_count(failed), tal_count(changed));
@ -2011,6 +2021,8 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg)
get_feerate(fee_states, get_feerate(fee_states,
channel->opener, channel->opener,
LOCAL)); LOCAL));
tal_free(channel->blockheight_states);
channel->blockheight_states = tal_steal(channel, blockheight_states);
/* Since we're about to send revoke, bump state again. */ /* Since we're about to send revoke, bump state again. */
if (!peer_sending_revocation(channel, added, fulfilled, failed, changed)) if (!peer_sending_revocation(channel, added, fulfilled, failed, changed))
@ -2087,6 +2099,7 @@ void peer_got_revoke(struct channel *channel, const u8 *msg)
size_t i; size_t i;
struct lightningd *ld = channel->peer->ld; struct lightningd *ld = channel->peer->ld;
struct fee_states *fee_states; struct fee_states *fee_states;
struct height_states *blockheight_states;
struct penalty_base *pbase; struct penalty_base *pbase;
struct commitment_revocation_payload *payload; struct commitment_revocation_payload *payload;
struct bitcoin_tx *penalty_tx; struct bitcoin_tx *penalty_tx;
@ -2095,10 +2108,12 @@ void peer_got_revoke(struct channel *channel, const u8 *msg)
&revokenum, &per_commitment_secret, &revokenum, &per_commitment_secret,
&next_per_commitment_point, &next_per_commitment_point,
&fee_states, &fee_states,
&blockheight_states,
&changed, &changed,
&pbase, &pbase,
&penalty_tx) &penalty_tx)
|| !fee_states_valid(fee_states, channel->opener)) { || !fee_states_valid(fee_states, channel->opener)
|| !height_states_valid(blockheight_states, channel->opener)) {
channel_internal_error(channel, "bad fromwire_channeld_got_revoke %s", channel_internal_error(channel, "bad fromwire_channeld_got_revoke %s",
tal_hex(channel, msg)); tal_hex(channel, msg));
return; return;
@ -2161,6 +2176,9 @@ void peer_got_revoke(struct channel *channel, const u8 *msg)
tal_free(channel->fee_states); tal_free(channel->fee_states);
channel->fee_states = tal_steal(channel, fee_states); channel->fee_states = tal_steal(channel, fee_states);
tal_free(channel->blockheight_states);
channel->blockheight_states = tal_steal(channel, blockheight_states);
/* FIXME: Check per_commitment_secret -> per_commit_point */ /* FIXME: Check per_commitment_secret -> per_commit_point */
update_per_commit_point(channel, &next_per_commitment_point); update_per_commit_point(channel, &next_per_commitment_point);

View File

@ -810,7 +810,7 @@ def test_penalty_htlc_tx_fulfill(node_factory, bitcoind, chainparams):
# reconnect with l1, which will fulfill the payment # reconnect with l1, which will fulfill the payment
l2.rpc.connect(l1.info['id'], 'localhost', l1.port) l2.rpc.connect(l1.info['id'], 'localhost', l1.port)
l2.daemon.wait_for_log('got commitsig .*: feerate 11000, 0 added, 1 fulfilled, 0 failed, 0 changed') l2.daemon.wait_for_log('got commitsig .*: feerate 11000, blockheight: 0, 0 added, 1 fulfilled, 0 failed, 0 changed')
l2.daemon.wait_for_log('coins payment_hash: {}'.format(sticky_inv['payment_hash'])) l2.daemon.wait_for_log('coins payment_hash: {}'.format(sticky_inv['payment_hash']))
# l2 moves on for closed l3 # l2 moves on for closed l3
@ -966,7 +966,7 @@ def test_penalty_htlc_tx_timeout(node_factory, bitcoind, chainparams):
# reconnect with l1, which will fulfill the payment # reconnect with l1, which will fulfill the payment
l2.rpc.connect(l1.info['id'], 'localhost', l1.port) l2.rpc.connect(l1.info['id'], 'localhost', l1.port)
l2.daemon.wait_for_log('got commitsig .*: feerate 11000, 0 added, 1 fulfilled, 0 failed, 0 changed') l2.daemon.wait_for_log('got commitsig .*: feerate 11000, blockheight: 0, 0 added, 1 fulfilled, 0 failed, 0 changed')
l2.daemon.wait_for_log('coins payment_hash: {}'.format(sticky_inv_2['payment_hash'])) l2.daemon.wait_for_log('coins payment_hash: {}'.format(sticky_inv_2['payment_hash']))
# l2 moves on for closed l3 # l2 moves on for closed l3

View File

@ -2014,4 +2014,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:1778bd4f49bef247c2b4789d1f7db3542fd606cbe186e299738aecbfbb2d44ae // SHA256STAMP:aa315b69d7586fe52d3f224d87db05201c9582ff9cacdb31b5e94a0287ec7e95

View File

@ -2014,4 +2014,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:1778bd4f49bef247c2b4789d1f7db3542fd606cbe186e299738aecbfbb2d44ae // SHA256STAMP:aa315b69d7586fe52d3f224d87db05201c9582ff9cacdb31b5e94a0287ec7e95

View File

@ -1329,4 +1329,4 @@ msgstr ""
#: wallet/test/run-wallet.c:1696 #: wallet/test/run-wallet.c:1696
msgid "INSERT INTO channels (id) VALUES (1);" msgid "INSERT INTO channels (id) VALUES (1);"
msgstr "" msgstr ""
# SHA256STAMP:03557959b260db89fed45406e7fae168e0ce9810b47351f22bbd8741a2910898 # SHA256STAMP:0867158b98125b1f5cb273f3e8fcc8bcac21f4a8b06032fb86a6ee1c34427ab2

View File

@ -132,16 +132,16 @@ bool feature_offered(const u8 *features UNNEEDED, size_t f UNNEEDED)
bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED) bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); } { fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for fromwire_channeld_got_commitsig */ /* Generated stub for fromwire_channeld_got_commitsig */
bool fromwire_channeld_got_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct fee_states **fee_states UNNEEDED, struct bitcoin_signature *signature UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, struct added_htlc **added UNNEEDED, struct fulfilled_htlc **fulfilled UNNEEDED, struct failed_htlc ***failed UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_tx **tx UNNEEDED) bool fromwire_channeld_got_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct bitcoin_signature *signature UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, struct added_htlc **added UNNEEDED, struct fulfilled_htlc **fulfilled UNNEEDED, struct failed_htlc ***failed UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_tx **tx UNNEEDED)
{ fprintf(stderr, "fromwire_channeld_got_commitsig called!\n"); abort(); } { fprintf(stderr, "fromwire_channeld_got_commitsig called!\n"); abort(); }
/* Generated stub for fromwire_channeld_got_revoke */ /* Generated stub for fromwire_channeld_got_revoke */
bool fromwire_channeld_got_revoke(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *revokenum UNNEEDED, struct secret *per_commitment_secret UNNEEDED, struct pubkey *next_per_commit_point UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct penalty_base **pbase UNNEEDED, struct bitcoin_tx **penalty_tx UNNEEDED) bool fromwire_channeld_got_revoke(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *revokenum UNNEEDED, struct secret *per_commitment_secret UNNEEDED, struct pubkey *next_per_commit_point UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct penalty_base **pbase UNNEEDED, struct bitcoin_tx **penalty_tx UNNEEDED)
{ fprintf(stderr, "fromwire_channeld_got_revoke called!\n"); abort(); } { fprintf(stderr, "fromwire_channeld_got_revoke called!\n"); abort(); }
/* Generated stub for fromwire_channeld_offer_htlc_reply */ /* Generated stub for fromwire_channeld_offer_htlc_reply */
bool fromwire_channeld_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u8 **failuremsg UNNEEDED, wirestring **failurestr UNNEEDED) bool fromwire_channeld_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u8 **failuremsg UNNEEDED, wirestring **failurestr UNNEEDED)
{ fprintf(stderr, "fromwire_channeld_offer_htlc_reply called!\n"); abort(); } { fprintf(stderr, "fromwire_channeld_offer_htlc_reply called!\n"); abort(); }
/* Generated stub for fromwire_channeld_sending_commitsig */ /* Generated stub for fromwire_channeld_sending_commitsig */
bool fromwire_channeld_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct penalty_base **pbase UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, struct bitcoin_signature **htlc_sigs UNNEEDED) bool fromwire_channeld_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct penalty_base **pbase UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, struct bitcoin_signature **htlc_sigs UNNEEDED)
{ fprintf(stderr, "fromwire_channeld_sending_commitsig called!\n"); abort(); } { fprintf(stderr, "fromwire_channeld_sending_commitsig called!\n"); abort(); }
/* Generated stub for fromwire_connectd_peer_connected */ /* Generated stub for fromwire_connectd_peer_connected */
bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, bool *incoming UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED) bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, bool *incoming UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)