Browse Source

channeld: Pass penalty_base back to lightningd on each commit

nifty/pset-pre
Christian Decker 5 years ago
committed by Rusty Russell
parent
commit
f9dab1e50a
  1. 1
      channeld/Makefile
  2. 3
      channeld/channel_wire.csv
  3. 14
      channeld/channeld.c
  4. 2
      lightningd/peer_htlcs.c
  5. 2
      wallet/test/run-wallet.c

1
channeld/Makefile

@ -69,6 +69,7 @@ CHANNELD_COMMON_OBJS := \
common/onionreply.o \
common/peer_billboard.o \
common/peer_failed.o \
common/penalty_base.o \
common/per_peer_state.o \
common/permute_tx.o \
common/ping.o \

3
channeld/channel_wire.csv

@ -100,9 +100,12 @@ msgdata,channel_fail_htlc,failed_htlc,failed_htlc,
msgtype,channel_got_funding_locked,1019
msgdata,channel_got_funding_locked,next_per_commit_point,pubkey,
#include <common/penalty_base.h>
# When we send a commitment_signed message, tell master.
msgtype,channel_sending_commitsig,1020
msgdata,channel_sending_commitsig,commitnum,u64,
msgdata,channel_sending_commitsig,pbase,?penalty_base,
msgdata,channel_sending_commitsig,fee_states,fee_states,
# SENT_ADD_COMMIT, SENT_REMOVE_ACK_COMMIT, SENT_ADD_ACK_COMMIT, SENT_REMOVE_COMMIT
msgdata,channel_sending_commitsig,num_changed,u16,

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

14
channeld/channeld.c

@ -725,6 +725,7 @@ static struct changed_htlc *changed_htlc_arr(const tal_t *ctx,
static u8 *sending_commitsig_msg(const tal_t *ctx,
u64 remote_commit_index,
struct penalty_base *pbase,
const struct fee_states *fee_states,
const struct htlc **changed_htlcs,
const struct bitcoin_signature *commit_sig,
@ -736,9 +737,8 @@ static u8 *sending_commitsig_msg(const tal_t *ctx,
/* We tell master what (of our) HTLCs peer will now be
* committed to. */
changed = changed_htlc_arr(tmpctx, changed_htlcs);
msg = towire_channel_sending_commitsig(ctx, remote_commit_index,
fee_states,
changed, commit_sig, htlc_sigs);
msg = towire_channel_sending_commitsig(ctx, remote_commit_index, pbase, fee_states, changed,
commit_sig, htlc_sigs);
return msg;
}
@ -930,6 +930,7 @@ static void send_commit(struct peer *peer)
const u8 *funding_wscript;
const struct htlc **htlc_map;
struct wally_tx_output *direct_outputs[NUM_SIDES];
struct penalty_base *pbase;
#if DEVELOPER
/* Hack to suppress all commit sends if dev_disconnect says to */
@ -1028,9 +1029,16 @@ static void send_commit(struct peer *peer)
calc_commitsigs(tmpctx, peer, txs, funding_wscript, htlc_map,
peer->next_index[REMOTE], &commit_sig);
if (direct_outputs[LOCAL] != NULL) {
pbase = penalty_base_new(tmpctx, peer->next_index[REMOTE],
txs[0], direct_outputs[LOCAL]);
} else
pbase = NULL;
status_debug("Telling master we're about to commit...");
/* Tell master to save this next commit to database, then wait. */
msg = sending_commitsig_msg(NULL, peer->next_index[REMOTE],
pbase,
peer->channel->fee_states,
changed_htlcs,
&commit_sig,

2
lightningd/peer_htlcs.c

@ -1669,11 +1669,13 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg)
struct bitcoin_signature commit_sig;
secp256k1_ecdsa_signature *htlc_sigs;
struct lightningd *ld = channel->peer->ld;
struct penalty_base *pbase;
channel->htlc_timeout = tal_free(channel->htlc_timeout);
if (!fromwire_channel_sending_commitsig(msg, msg,
&commitnum,
&pbase,
&fee_states,
&changed_htlcs,
&commit_sig, &htlc_sigs)

2
wallet/test/run-wallet.c

@ -122,7 +122,7 @@ bool fromwire_channel_got_revoke(const tal_t *ctx UNNEEDED, const void *p UNNEED
bool fromwire_channel_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u8 **failuremsg UNNEEDED, wirestring **failurestr UNNEEDED)
{ fprintf(stderr, "fromwire_channel_offer_htlc_reply called!\n"); abort(); }
/* Generated stub for fromwire_channel_sending_commitsig */
bool fromwire_channel_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, secp256k1_ecdsa_signature **htlc_sigs UNNEEDED)
bool fromwire_channel_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, secp256k1_ecdsa_signature **htlc_sigs UNNEEDED)
{ fprintf(stderr, "fromwire_channel_sending_commitsig called!\n"); abort(); }
/* Generated stub for fromwire_connect_peer_connected */
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)

Loading…
Cancel
Save