Browse Source

state: fix BITCOIN_HTLC_TOTHEM_SPENT idata.

We use both union fields idata->btc and idata->htlc, which is clearly
wrong.  Have peer_tx_revealed_r_value return the HTLC it's talking
about.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
0db3c03ed1
  1. 5
      state.c
  2. 4
      state.h
  3. 5
      test/test_state_coverage.c

5
state.c

@ -757,10 +757,11 @@ enum command_status state(const tal_t *ctx,
return next_state(peer, cstatus, return next_state(peer, cstatus,
BITS_TO_STATE(bits)); BITS_TO_STATE(bits));
} else if (input_is(input, BITCOIN_HTLC_TOTHEM_SPENT)) { } else if (input_is(input, BITCOIN_HTLC_TOTHEM_SPENT)) {
const struct htlc *htlc;
/* They revealed R value. */ /* They revealed R value. */
peer_tx_revealed_r_value(peer, idata->btc); htlc = peer_tx_revealed_r_value(peer, idata->btc);
/* We don't care any more. */ /* We don't care any more. */
peer_unwatch_htlc_output(peer, idata->htlc, peer_unwatch_htlc_output(peer, htlc,
INPUT_NO_MORE_HTLCS); INPUT_NO_MORE_HTLCS);
return unchanged_state(cstatus); return unchanged_state(cstatus);
} else if (input_is(input, BITCOIN_HTLC_TOTHEM_TIMEOUT)){ } else if (input_is(input, BITCOIN_HTLC_TOTHEM_TIMEOUT)){

4
state.h

@ -94,8 +94,8 @@ void peer_htlc_done(struct peer *peer);
void peer_htlc_aborted(struct peer *peer); void peer_htlc_aborted(struct peer *peer);
/* An on-chain transaction revealed an R value. */ /* An on-chain transaction revealed an R value. */
void peer_tx_revealed_r_value(struct peer *peer, const struct htlc *peer_tx_revealed_r_value(struct peer *peer,
const struct bitcoin_event *btc); const struct bitcoin_event *btc);
/* Create various kinds of packets, allocated off @ctx */ /* Create various kinds of packets, allocated off @ctx */
Pkt *pkt_open(const tal_t *ctx, const struct peer *peer, Pkt *pkt_open(const tal_t *ctx, const struct peer *peer,

5
test/test_state_coverage.c

@ -1465,11 +1465,12 @@ void peer_htlc_declined(struct peer *peer, const Pkt *pkt)
peer->htlc_declined = true; peer->htlc_declined = true;
} }
void peer_tx_revealed_r_value(struct peer *peer, const struct htlc *peer_tx_revealed_r_value(struct peer *peer,
const struct bitcoin_event *btc) const struct bitcoin_event *btc)
{ {
const struct htlc *htlc = (struct htlc *)btc; const struct htlc *htlc = (struct htlc *)btc;
add_rval(peer, htlc->id); add_rval(peer, htlc->id);
return htlc;
} }
static const char *check_changes(const struct peer *old, struct peer *new, static const char *check_changes(const struct peer *old, struct peer *new,

Loading…
Cancel
Save