mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
protocol: remove tx_version field.
It's trivial to add later as an optional field. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ee3af28980
commit
c4d5a85b4e
6
anchor.c
6
anchor.c
@ -26,12 +26,6 @@ struct bitcoin_tx *anchor_tx_create(const tal_t *ctx,
|
|||||||
n_out = 1 + !!o1->anchor->change + !!o2->anchor->change;
|
n_out = 1 + !!o1->anchor->change + !!o2->anchor->change;
|
||||||
tx = bitcoin_tx(ctx, o1->anchor->n_inputs+o2->anchor->n_inputs, n_out);
|
tx = bitcoin_tx(ctx, o1->anchor->n_inputs+o2->anchor->n_inputs, n_out);
|
||||||
|
|
||||||
/* Override version to use lesser of two versions. */
|
|
||||||
if (o1->tx_version < o2->tx_version)
|
|
||||||
tx->version = o1->tx_version;
|
|
||||||
else
|
|
||||||
tx->version = o2->tx_version;
|
|
||||||
|
|
||||||
/* Populate inputs. */
|
/* Populate inputs. */
|
||||||
for (i = 0; i < o1->anchor->n_inputs; i++) {
|
for (i = 0; i < o1->anchor->n_inputs; i++) {
|
||||||
BitcoinInput *pb = o1->anchor->inputs[i];
|
BitcoinInput *pb = o1->anchor->inputs[i];
|
||||||
|
@ -243,7 +243,6 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count,
|
|||||||
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
tx->version = BITCOIN_TX_VERSION;
|
|
||||||
tx->output_count = output_count;
|
tx->output_count = output_count;
|
||||||
tx->output = tal_arrz(tx, struct bitcoin_tx_output, output_count);
|
tx->output = tal_arrz(tx, struct bitcoin_tx_output, output_count);
|
||||||
tx->input_count = input_count;
|
tx->input_count = input_count;
|
||||||
@ -254,6 +253,7 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count,
|
|||||||
tx->input[i].sequence_number = 0xFFFFFFFF;
|
tx->input[i].sequence_number = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
tx->lock_time = 0;
|
tx->lock_time = 0;
|
||||||
|
tx->version = 1;
|
||||||
|
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include "shadouble.h"
|
#include "shadouble.h"
|
||||||
|
|
||||||
#define BITCOIN_TX_VERSION 1
|
|
||||||
|
|
||||||
/* We unpack varints for our in-memory representation */
|
/* We unpack varints for our in-memory representation */
|
||||||
#define varint_t u64
|
#define varint_t u64
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ const ProtobufCMessageDescriptor anchor__descriptor =
|
|||||||
(ProtobufCMessageInit) anchor__init,
|
(ProtobufCMessageInit) anchor__init,
|
||||||
NULL,NULL,NULL /* reserved[123] */
|
NULL,NULL,NULL /* reserved[123] */
|
||||||
};
|
};
|
||||||
static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
|
static const ProtobufCFieldDescriptor open_channel__field_descriptors[6] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"locktime_seconds",
|
"locktime_seconds",
|
||||||
@ -1333,18 +1333,6 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
|
|||||||
0, /* flags */
|
0, /* flags */
|
||||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"tx_version",
|
|
||||||
8,
|
|
||||||
PROTOBUF_C_LABEL_REQUIRED,
|
|
||||||
PROTOBUF_C_TYPE_UINT32,
|
|
||||||
0, /* quantifier_offset */
|
|
||||||
offsetof(OpenChannel, tx_version),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0, /* flags */
|
|
||||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
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 */
|
||||||
@ -1353,12 +1341,11 @@ static const unsigned open_channel__field_indices_by_name[] = {
|
|||||||
1, /* field[1] = locktime_blocks */
|
1, /* field[1] = locktime_blocks */
|
||||||
0, /* field[0] = locktime_seconds */
|
0, /* field[0] = locktime_seconds */
|
||||||
2, /* field[2] = revocation_hash */
|
2, /* field[2] = revocation_hash */
|
||||||
6, /* field[6] = tx_version */
|
|
||||||
};
|
};
|
||||||
static const ProtobufCIntRange open_channel__number_ranges[1 + 1] =
|
static const ProtobufCIntRange open_channel__number_ranges[1 + 1] =
|
||||||
{
|
{
|
||||||
{ 2, 0 },
|
{ 2, 0 },
|
||||||
{ 0, 7 }
|
{ 0, 6 }
|
||||||
};
|
};
|
||||||
const ProtobufCMessageDescriptor open_channel__descriptor =
|
const ProtobufCMessageDescriptor open_channel__descriptor =
|
||||||
{
|
{
|
||||||
@ -1368,7 +1355,7 @@ const ProtobufCMessageDescriptor open_channel__descriptor =
|
|||||||
"OpenChannel",
|
"OpenChannel",
|
||||||
"",
|
"",
|
||||||
sizeof(OpenChannel),
|
sizeof(OpenChannel),
|
||||||
7,
|
6,
|
||||||
open_channel__field_descriptors,
|
open_channel__field_descriptors,
|
||||||
open_channel__field_indices_by_name,
|
open_channel__field_indices_by_name,
|
||||||
1, open_channel__number_ranges,
|
1, open_channel__number_ranges,
|
||||||
@ -1540,7 +1527,7 @@ const ProtobufCMessageDescriptor update__descriptor =
|
|||||||
(ProtobufCMessageInit) update__init,
|
(ProtobufCMessageInit) update__init,
|
||||||
NULL,NULL,NULL /* reserved[123] */
|
NULL,NULL,NULL /* reserved[123] */
|
||||||
};
|
};
|
||||||
static const ProtobufCFieldDescriptor update_accept__field_descriptors[3] =
|
static const ProtobufCFieldDescriptor update_accept__field_descriptors[2] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"sig",
|
"sig",
|
||||||
@ -1554,18 +1541,6 @@ static const ProtobufCFieldDescriptor update_accept__field_descriptors[3] =
|
|||||||
0, /* flags */
|
0, /* flags */
|
||||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"old_anchor_sig",
|
|
||||||
2,
|
|
||||||
PROTOBUF_C_LABEL_OPTIONAL,
|
|
||||||
PROTOBUF_C_TYPE_MESSAGE,
|
|
||||||
0, /* quantifier_offset */
|
|
||||||
offsetof(UpdateAccept, old_anchor_sig),
|
|
||||||
&signature__descriptor,
|
|
||||||
NULL,
|
|
||||||
0, /* flags */
|
|
||||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"revocation_hash",
|
"revocation_hash",
|
||||||
3,
|
3,
|
||||||
@ -1580,14 +1555,14 @@ static const ProtobufCFieldDescriptor update_accept__field_descriptors[3] =
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
static const unsigned update_accept__field_indices_by_name[] = {
|
static const unsigned update_accept__field_indices_by_name[] = {
|
||||||
1, /* field[1] = old_anchor_sig */
|
1, /* field[1] = revocation_hash */
|
||||||
2, /* field[2] = revocation_hash */
|
|
||||||
0, /* field[0] = sig */
|
0, /* field[0] = sig */
|
||||||
};
|
};
|
||||||
static const ProtobufCIntRange update_accept__number_ranges[1 + 1] =
|
static const ProtobufCIntRange update_accept__number_ranges[2 + 1] =
|
||||||
{
|
{
|
||||||
{ 1, 0 },
|
{ 1, 0 },
|
||||||
{ 0, 3 }
|
{ 3, 1 },
|
||||||
|
{ 0, 2 }
|
||||||
};
|
};
|
||||||
const ProtobufCMessageDescriptor update_accept__descriptor =
|
const ProtobufCMessageDescriptor update_accept__descriptor =
|
||||||
{
|
{
|
||||||
@ -1597,10 +1572,10 @@ const ProtobufCMessageDescriptor update_accept__descriptor =
|
|||||||
"UpdateAccept",
|
"UpdateAccept",
|
||||||
"",
|
"",
|
||||||
sizeof(UpdateAccept),
|
sizeof(UpdateAccept),
|
||||||
3,
|
2,
|
||||||
update_accept__field_descriptors,
|
update_accept__field_descriptors,
|
||||||
update_accept__field_indices_by_name,
|
update_accept__field_indices_by_name,
|
||||||
1, update_accept__number_ranges,
|
2, update_accept__number_ranges,
|
||||||
(ProtobufCMessageInit) update_accept__init,
|
(ProtobufCMessageInit) update_accept__init,
|
||||||
NULL,NULL,NULL /* reserved[123] */
|
NULL,NULL,NULL /* reserved[123] */
|
||||||
};
|
};
|
||||||
|
@ -196,10 +196,6 @@ struct _OpenChannel
|
|||||||
* The anchor transaction details.
|
* The anchor transaction details.
|
||||||
*/
|
*/
|
||||||
Anchor *anchor;
|
Anchor *anchor;
|
||||||
/*
|
|
||||||
* Maximum transaction version we support.
|
|
||||||
*/
|
|
||||||
uint32_t tx_version;
|
|
||||||
OpenChannel__LocktimeCase locktime_case;
|
OpenChannel__LocktimeCase locktime_case;
|
||||||
union {
|
union {
|
||||||
uint32_t locktime_seconds;
|
uint32_t locktime_seconds;
|
||||||
@ -208,7 +204,7 @@ struct _OpenChannel
|
|||||||
};
|
};
|
||||||
#define OPEN_CHANNEL__INIT \
|
#define OPEN_CHANNEL__INIT \
|
||||||
{ PROTOBUF_C_MESSAGE_INIT (&open_channel__descriptor) \
|
{ PROTOBUF_C_MESSAGE_INIT (&open_channel__descriptor) \
|
||||||
, NULL, NULL, 0, NULL, 0, OPEN_CHANNEL__LOCKTIME__NOT_SET, {} }
|
, NULL, NULL, 0, NULL, OPEN_CHANNEL__LOCKTIME__NOT_SET, {} }
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -290,10 +286,6 @@ struct _UpdateAccept
|
|||||||
* Signature for your new commitment tx.
|
* Signature for your new commitment tx.
|
||||||
*/
|
*/
|
||||||
Signature *sig;
|
Signature *sig;
|
||||||
/*
|
|
||||||
* Signature for old anchor (if any)
|
|
||||||
*/
|
|
||||||
Signature *old_anchor_sig;
|
|
||||||
/*
|
/*
|
||||||
* Hash for which I will supply preimage to revoke this new commit tx.
|
* Hash for which I will supply preimage to revoke this new commit tx.
|
||||||
*/
|
*/
|
||||||
@ -301,7 +293,7 @@ struct _UpdateAccept
|
|||||||
};
|
};
|
||||||
#define UPDATE_ACCEPT__INIT \
|
#define UPDATE_ACCEPT__INIT \
|
||||||
{ PROTOBUF_C_MESSAGE_INIT (&update_accept__descriptor) \
|
{ PROTOBUF_C_MESSAGE_INIT (&update_accept__descriptor) \
|
||||||
, NULL, NULL, NULL }
|
, NULL, NULL }
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,8 +83,6 @@ message open_channel {
|
|||||||
required uint64 commitment_fee = 6;
|
required uint64 commitment_fee = 6;
|
||||||
// The anchor transaction details.
|
// The anchor transaction details.
|
||||||
required anchor anchor = 7;
|
required anchor anchor = 7;
|
||||||
// Maximum transaction version we support.
|
|
||||||
required uint32 tx_version = 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supply signature for commitment tx
|
// Supply signature for commitment tx
|
||||||
|
1
pkt.c
1
pkt.c
@ -50,7 +50,6 @@ struct pkt *openchannel_pkt(const tal_t *ctx,
|
|||||||
o.anchor = anchor;
|
o.anchor = anchor;
|
||||||
o.locktime_case = OPEN_CHANNEL__LOCKTIME_LOCKTIME_SECONDS;
|
o.locktime_case = OPEN_CHANNEL__LOCKTIME_LOCKTIME_SECONDS;
|
||||||
o.locktime_seconds = rel_locktime_seconds;
|
o.locktime_seconds = rel_locktime_seconds;
|
||||||
o.tx_version = BITCOIN_TX_VERSION;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t len = open_channel__get_packed_size(&o);
|
size_t len = open_channel__get_packed_size(&o);
|
||||||
|
Loading…
Reference in New Issue
Block a user