Skip to content

Commit

Permalink
subdaemons: pass back and forth the htlc points.
Browse files Browse the repository at this point in the history
Openingd sets it to the same as the payment point for the remote side.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Nov 16, 2017
1 parent 654c2f4 commit fc05779
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
3 changes: 1 addition & 2 deletions channeld/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@ static void init_channel(struct peer *peer)
&funding_pubkey[REMOTE],
&points[REMOTE].revocation,
&points[REMOTE].payment,
&points[REMOTE].htlc,
&points[REMOTE].delayed_payment,
&peer->remote_per_commit,
&peer->old_remote_per_commit,
Expand Down Expand Up @@ -2057,8 +2058,6 @@ static void init_channel(struct peer *peer)
&funding_signed))
master_badmsg(WIRE_CHANNEL_INIT, msg);

points[REMOTE].htlc = points[REMOTE].payment;

status_trace("init %s: remote_per_commit = %s, old_remote_per_commit = %s"
" next_idx_local = %"PRIu64
" next_idx_remote = %"PRIu64
Expand Down
7 changes: 4 additions & 3 deletions channeld/channel_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ channel_init,,feerate_per_kw,u32
channel_init,,first_commit_sig,secp256k1_ecdsa_signature
channel_init,,crypto_state,struct crypto_state
channel_init,,remote_fundingkey,struct pubkey
channel_init,,revocation_basepoint,struct pubkey
channel_init,,payment_basepoint,struct pubkey
channel_init,,delayed_payment_basepoint,struct pubkey
channel_init,,remote_revocation_basepoint,struct pubkey
channel_init,,remote_payment_basepoint,struct pubkey
channel_init,,remote_htlc_basepoint,struct pubkey
channel_init,,remote_delayed_payment_basepoint,struct pubkey
channel_init,,remote_per_commit,struct pubkey
channel_init,,old_remote_per_commit,struct pubkey
channel_init,,funder,enum side
Expand Down
8 changes: 4 additions & 4 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ static enum watch_result funding_spent(struct peer *peer,
&ourkey,
peer->funder,
&peer->channel_info->theirbase.payment,
&peer->channel_info->theirbase.htlc,
&peer->channel_info->theirbase.delayed_payment,
tx,
block->height,
Expand Down Expand Up @@ -2093,6 +2094,7 @@ static bool peer_start_channeld(struct peer *peer,
&peer->channel_info->remote_fundingkey,
&peer->channel_info->theirbase.revocation,
&peer->channel_info->theirbase.payment,
&peer->channel_info->theirbase.htlc,
&peer->channel_info->theirbase.delayed_payment,
&peer->channel_info->remote_per_commit,
&peer->channel_info->old_remote_per_commit,
Expand Down Expand Up @@ -2167,6 +2169,7 @@ static void opening_funder_finished(struct subd *opening, const u8 *resp,
&cs,
&channel_info->theirbase.revocation,
&channel_info->theirbase.payment,
&channel_info->theirbase.htlc,
&channel_info->theirbase.delayed_payment,
&channel_info->remote_per_commit,
&fc->peer->minimum_depth,
Expand All @@ -2177,8 +2180,6 @@ static void opening_funder_finished(struct subd *opening, const u8 *resp,
tal_hex(resp, resp));
return;
}
/* FIXME */
channel_info->theirbase.htlc = channel_info->theirbase.payment;

/* old_remote_per_commit not valid yet, copy valid one. */
channel_info->old_remote_per_commit = channel_info->remote_per_commit;
Expand Down Expand Up @@ -2284,6 +2285,7 @@ static void opening_fundee_finished(struct subd *opening,
&cs,
&channel_info->theirbase.revocation,
&channel_info->theirbase.payment,
&channel_info->theirbase.htlc,
&channel_info->theirbase.delayed_payment,
&channel_info->remote_per_commit,
&channel_info->remote_fundingkey,
Expand All @@ -2298,8 +2300,6 @@ static void opening_fundee_finished(struct subd *opening,
tal_hex(reply, reply));
return;
}
/* FIXME */
channel_info->theirbase.htlc = channel_info->theirbase.payment;

/* old_remote_per_commit not valid yet, copy valid one. */
channel_info->old_remote_per_commit = channel_info->remote_per_commit;
Expand Down
3 changes: 2 additions & 1 deletion onchaind/onchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,7 @@ int main(int argc, char *argv[])
&our_wallet_pubkey,
&funder,
&remote_payment_basepoint,
&remote_htlc_basepoint,
&remote_delayed_payment_basepoint,
tx,
&tx_blockheight,
Expand All @@ -1982,7 +1983,7 @@ int main(int argc, char *argv[])
&num_htlcs)) {
master_badmsg(WIRE_ONCHAIN_INIT, msg);
}
remote_htlc_basepoint = remote_payment_basepoint;

derive_basepoints(&seed, NULL, &basepoints, &secrets, &shaseed);
bitcoin_txid(tx, &txid);

Expand Down
1 change: 1 addition & 0 deletions onchaind/onchain_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ onchain_init,,ourwallet_pubkey,struct pubkey
# We need these two for commit number obscurer
onchain_init,,funder,enum side
onchain_init,,remote_payment_basepoint,struct pubkey
onchain_init,,remote_htlc_basepoint,struct pubkey
onchain_init,,remote_delayed_payment_basepoint,struct pubkey
onchain_init,,tx,struct bitcoin_tx
onchain_init,,tx_blockheight,u32
Expand Down
2 changes: 2 additions & 0 deletions openingd/opening.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ static u8 *funder_channel(struct state *state,
&state->cs,
&theirs.revocation,
&theirs.payment,
&theirs.htlc,
&theirs.delayed_payment,
&state->next_per_commit[REMOTE],
minimum_depth,
Expand Down Expand Up @@ -665,6 +666,7 @@ static u8 *fundee_channel(struct state *state,
&state->cs,
&theirs.revocation,
&theirs.payment,
&theirs.htlc,
&theirs.delayed_payment,
&state->next_per_commit[REMOTE],
&their_funding_pubkey,
Expand Down
2 changes: 2 additions & 0 deletions openingd/opening_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ opening_funder_reply,,first_commit_sig,secp256k1_ecdsa_signature
opening_funder_reply,,crypto_state,struct crypto_state
opening_funder_reply,,revocation_basepoint,struct pubkey
opening_funder_reply,,payment_basepoint,struct pubkey
opening_funder_reply,,htlc_basepoint,struct pubkey
opening_funder_reply,,delayed_payment_basepoint,struct pubkey
opening_funder_reply,,their_per_commit_point,struct pubkey
opening_funder_reply,,minimum_depth,u32
Expand All @@ -59,6 +60,7 @@ opening_fundee_reply,,first_commit_sig,secp256k1_ecdsa_signature
opening_fundee_reply,,crypto_state,struct crypto_state
opening_fundee_reply,,revocation_basepoint,struct pubkey
opening_fundee_reply,,payment_basepoint,struct pubkey
opening_fundee_reply,,htlc_basepoint,struct pubkey
opening_fundee_reply,,delayed_payment_basepoint,struct pubkey
opening_fundee_reply,,their_per_commit_point,struct pubkey
opening_fundee_reply,,remote_fundingkey,struct pubkey
Expand Down

0 comments on commit fc05779

Please sign in to comment.