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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-06-08 06:29:15 +09:30
parent baf5d11643
commit 4dd6b8e385
5 changed files with 11 additions and 10 deletions

View File

@@ -24,12 +24,13 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx,
tx->input[0].txid = *anchor_txid; tx->input[0].txid = *anchor_txid;
tx->input[0].index = anchor_output; 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); return tal_free(tx);
if (!proto_to_pubkey(theirs->anchor->pubkey, &theirkey)) if (!proto_to_pubkey(theirs->final, &theirkey))
return tal_free(tx); return tal_free(tx);
proto_to_sha256(ours->revocation_hash, &redeem); proto_to_sha256(ours->revocation_hash, &redeem);
/* First output is a P2SH to a complex redeem script (usu. for me) */ /* First output is a P2SH to a complex redeem script (usu. for me) */
redeemscript = bitcoin_redeem_revocable(tx, &ourkey, redeemscript = bitcoin_redeem_revocable(tx, &ourkey,
ours->locktime_seconds, 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; tx->output[0].amount = ours->anchor->total - ours->commitment_fee;
/* Second output is a P2SH payment to them. */ /* 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); return tal_free(tx);
tx->output[1].script = scriptpubkey_p2sh(ctx, tx->output[1].script = scriptpubkey_p2sh(ctx,
bitcoin_redeem_single(ctx, bitcoin_redeem_single(ctx,

View File

@@ -1513,12 +1513,12 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
}, },
{ {
"to_me", "final",
5, 5,
PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */ 0, /* quantifier_offset */
offsetof(OpenChannel, to_me), offsetof(OpenChannel, final),
&bitcoin_pubkey__descriptor, &bitcoin_pubkey__descriptor,
NULL, NULL,
0, /* flags */ 0, /* flags */
@@ -1564,10 +1564,10 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
static const unsigned open_channel__field_indices_by_name[] = { static const unsigned open_channel__field_indices_by_name[] = {
5, /* field[5] = anchor */ 5, /* field[5] = anchor */
4, /* field[4] = commitment_fee */ 4, /* field[4] = commitment_fee */
3, /* field[3] = final */
1, /* field[1] = locktime_seconds */ 1, /* field[1] = locktime_seconds */
2, /* field[2] = revocation_hash */ 2, /* field[2] = revocation_hash */
0, /* field[0] = seed */ 0, /* field[0] = seed */
3, /* field[3] = to_me */
6, /* field[6] = tx_version */ 6, /* field[6] = tx_version */
}; };
static const ProtobufCIntRange open_channel__number_ranges[2 + 1] = static const ProtobufCIntRange open_channel__number_ranges[2 + 1] =

View File

@@ -194,7 +194,7 @@ struct _OpenChannel
/* /*
* How to pay money to us from commit_tx. * How to pay money to us from commit_tx.
*/ */
BitcoinPubkey *to_me; BitcoinPubkey *final;
/* /*
* How much transaction fee we'll pay for commitment txs. * How much transaction fee we'll pay for commitment txs.
*/ */

View File

@@ -77,7 +77,7 @@ message open_channel {
// Hash seed for revoking commitment transactions. // Hash seed for revoking commitment transactions.
required sha256_hash revocation_hash = 4; required sha256_hash revocation_hash = 4;
// How to pay money to us from commit_tx. // 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. // How much transaction fee we'll pay for commitment txs.
required uint64 commitment_fee = 6; required uint64 commitment_fee = 6;
// The anchor transaction details. // The anchor transaction details.

2
pkt.c
View File

@@ -64,7 +64,7 @@ struct pkt *openchannel_pkt(const tal_t *ctx,
o.seed = seed; o.seed = seed;
o.revocation_hash = sha256_to_proto(ctx, revocation_hash); 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.commitment_fee = commitment_fee;
o.anchor = anchor; o.anchor = anchor;
o.locktime_seconds = rel_locktime_seconds; o.locktime_seconds = rel_locktime_seconds;