From fc05779f78d63fab799849f66bd7c1bc9e84b3bc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 15 Nov 2017 16:51:39 +1030 Subject: [PATCH] subdaemons: pass back and forth the htlc points. Openingd sets it to the same as the payment point for the remote side. Signed-off-by: Rusty Russell --- channeld/channel.c | 3 +-- channeld/channel_wire.csv | 7 ++++--- lightningd/peer_control.c | 8 ++++---- onchaind/onchain.c | 3 ++- onchaind/onchain_wire.csv | 1 + openingd/opening.c | 2 ++ openingd/opening_wire.csv | 2 ++ 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/channeld/channel.c b/channeld/channel.c index 8ef9f0b9a..e5ef4e2d7 100644 --- a/channeld/channel.c +++ b/channeld/channel.c @@ -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, @@ -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 diff --git a/channeld/channel_wire.csv b/channeld/channel_wire.csv index 8c761e852..4efa901bb 100644 --- a/channeld/channel_wire.csv +++ b/channeld/channel_wire.csv @@ -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 diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 43a8476b9..cc8ad66cd 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -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, @@ -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, @@ -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, @@ -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; @@ -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, @@ -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; diff --git a/onchaind/onchain.c b/onchaind/onchain.c index d26b3388d..ab4d53280 100644 --- a/onchaind/onchain.c +++ b/onchaind/onchain.c @@ -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, @@ -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); diff --git a/onchaind/onchain_wire.csv b/onchaind/onchain_wire.csv index 97a4c6ceb..2c7912b17 100644 --- a/onchaind/onchain_wire.csv +++ b/onchaind/onchain_wire.csv @@ -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 diff --git a/openingd/opening.c b/openingd/opening.c index 9df9adc0f..687913885 100644 --- a/openingd/opening.c +++ b/openingd/opening.c @@ -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, @@ -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, diff --git a/openingd/opening_wire.csv b/openingd/opening_wire.csv index 1829fa5a3..3ebaa8dc7 100644 --- a/openingd/opening_wire.csv +++ b/openingd/opening_wire.csv @@ -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 @@ -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