From 4dd6b8e385e57c3df5c4ba7c5b2f791e501b4e70 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 8 Jun 2015 06:29:15 +0930 Subject: [PATCH] lightning.proto: Rename 'to_me' to 'final', use for commit_tx. This is where the commit tx outputs should pay to. Signed-off-by: Rusty Russell --- commit_tx.c | 9 +++++---- lightning.pb-c.c | 6 +++--- lightning.pb-c.h | 2 +- lightning.proto | 2 +- pkt.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/commit_tx.c b/commit_tx.c index 0aaf1ffb8..3d7eafcfa 100644 --- a/commit_tx.c +++ b/commit_tx.c @@ -24,12 +24,13 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx, tx->input[0].txid = *anchor_txid; tx->input[0].index = anchor_output; - if (!proto_to_pubkey(ours->anchor->pubkey, &ourkey)) + /* Output goes to our final pubkeys */ + if (!proto_to_pubkey(ours->final, &ourkey)) return tal_free(tx); - if (!proto_to_pubkey(theirs->anchor->pubkey, &theirkey)) + if (!proto_to_pubkey(theirs->final, &theirkey)) return tal_free(tx); proto_to_sha256(ours->revocation_hash, &redeem); - + /* First output is a P2SH to a complex redeem script (usu. for me) */ redeemscript = bitcoin_redeem_revocable(tx, &ourkey, ours->locktime_seconds, @@ -43,7 +44,7 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx, tx->output[0].amount = ours->anchor->total - ours->commitment_fee; /* Second output is a P2SH payment to them. */ - if (!proto_to_pubkey(theirs->to_me, &to_me)) + if (!proto_to_pubkey(theirs->final, &to_me)) return tal_free(tx); tx->output[1].script = scriptpubkey_p2sh(ctx, bitcoin_redeem_single(ctx, diff --git a/lightning.pb-c.c b/lightning.pb-c.c index bf4a6a3b3..3476e4694 100644 --- a/lightning.pb-c.c +++ b/lightning.pb-c.c @@ -1513,12 +1513,12 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] = 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "to_me", + "final", 5, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - offsetof(OpenChannel, to_me), + offsetof(OpenChannel, final), &bitcoin_pubkey__descriptor, NULL, 0, /* flags */ @@ -1564,10 +1564,10 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] = static const unsigned open_channel__field_indices_by_name[] = { 5, /* field[5] = anchor */ 4, /* field[4] = commitment_fee */ + 3, /* field[3] = final */ 1, /* field[1] = locktime_seconds */ 2, /* field[2] = revocation_hash */ 0, /* field[0] = seed */ - 3, /* field[3] = to_me */ 6, /* field[6] = tx_version */ }; static const ProtobufCIntRange open_channel__number_ranges[2 + 1] = diff --git a/lightning.pb-c.h b/lightning.pb-c.h index df8f90c29..6f2ff5d63 100644 --- a/lightning.pb-c.h +++ b/lightning.pb-c.h @@ -194,7 +194,7 @@ struct _OpenChannel /* * How to pay money to us from commit_tx. */ - BitcoinPubkey *to_me; + BitcoinPubkey *final; /* * How much transaction fee we'll pay for commitment txs. */ diff --git a/lightning.proto b/lightning.proto index 509af4245..d4d9ad6c3 100644 --- a/lightning.proto +++ b/lightning.proto @@ -77,7 +77,7 @@ message open_channel { // Hash seed for revoking commitment transactions. required sha256_hash revocation_hash = 4; // How to pay money to us from commit_tx. - required bitcoin_pubkey to_me = 5; + required bitcoin_pubkey final = 5; // How much transaction fee we'll pay for commitment txs. required uint64 commitment_fee = 6; // The anchor transaction details. diff --git a/pkt.c b/pkt.c index aa22e7e44..1955f4fa9 100644 --- a/pkt.c +++ b/pkt.c @@ -64,7 +64,7 @@ struct pkt *openchannel_pkt(const tal_t *ctx, o.seed = seed; o.revocation_hash = sha256_to_proto(ctx, revocation_hash); - o.to_me = pubkey_to_proto(ctx, to_me); + o.final = pubkey_to_proto(ctx, to_me); o.commitment_fee = commitment_fee; o.anchor = anchor; o.locktime_seconds = rel_locktime_seconds;