Browse Source

Rename "anchor sig" to "anchor scriptsigs" to be clearer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 10 years ago
parent
commit
67f98fe6b6
  1. 8
      Makefile
  2. 5
      leak-anchor-sigs.c
  3. 76
      lightning.pb-c.c
  4. 46
      lightning.pb-c.h
  5. 6
      lightning.proto
  6. 4
      open-anchor-scriptsigs.c
  7. 6
      pkt.c
  8. 2
      pkt.h

8
Makefile

@ -3,14 +3,14 @@
# Needs to have oneof support: Ubuntu vivid's is too old :(
PROTOCC:=protoc-c
PROGRAMS := open-channel open-anchor-sig leak-anchor-sigs open-commit-sig check-commit-sig
PROGRAMS := open-channel open-anchor-scriptsigs leak-anchor-sigs open-commit-sig check-commit-sig
HELPER_OBJS := base58.o lightning.pb-c.o shadouble.o pkt.o bitcoin_script.o permute_tx.o signature.o bitcoin_tx.o bitcoin_address.o anchor.o commit_tx.o pubkey.o
CCAN_OBJS := ccan-crypto-sha256.o ccan-crypto-shachain.o ccan-err.o ccan-tal.o ccan-tal-str.o ccan-take.o ccan-list.o ccan-str.o ccan-opt-helpers.o ccan-opt.o ccan-opt-parse.o ccan-opt-usage.o ccan-read_write_all.o ccan-str-hex.o ccan-tal-grab_file.o ccan-noerr.o
OPEN_CHANNEL_OBJS := open-channel.o
OPEN_ANCHOR_SIG_OBJS := open-anchor-sig.o
OPEN_ANCHOR_SCRIPTSIGS_OBJS := open-anchor-scriptsigs.o
LEAK_ANCHOR_SIGS_OBJS := leak-anchor-sigs.o
OPEN_COMMIT_SIG_OBJS := open-commit-sig.o
@ -28,8 +28,8 @@ lightning.pb-c.c lightning.pb-c.h: lightning.proto
open-channel: $(OPEN_CHANNEL_OBJS) $(HELPER_OBJS) $(CCAN_OBJS)
$(OPEN_CHANNEL_OBJS): $(HEADERS)
open-anchor-sig: $(OPEN_ANCHOR_SIG_OBJS) $(HELPER_OBJS) $(CCAN_OBJS)
$(OPEN_ANCHOR_SIG_OBJS): $(HEADERS)
open-anchor-scriptsigs: $(OPEN_ANCHOR_SCRIPTSIGS_OBJS) $(HELPER_OBJS) $(CCAN_OBJS)
$(OPEN_ANCHOR_SCRIPTSIGS_OBJS): $(HEADERS)
leak-anchor-sigs: $(LEAK_ANCHOR_SIGS_OBJS) $(HELPER_OBJS) $(CCAN_OBJS)
$(LEAK_ANCHOR_SIGS_OBJS): $(HEADERS)

5
leak-anchor-sigs.c

@ -9,7 +9,7 @@
int main(int argc, char *argv[])
{
const tal_t *ctx = tal_arr(NULL, char, 0);
OpenAnchorSig *s;
OpenAnchorScriptsigs *s;
struct pkt *pkt;
err_set_progname(argv[0]);
@ -24,7 +24,8 @@ int main(int argc, char *argv[])
if (argc != 2)
opt_usage_and_exit(NULL);
s = pkt_from_file(argv[1], PKT__PKT_OPEN_ANCHOR_SIG)->open_anchor_sig;
s = pkt_from_file(argv[1], PKT__PKT_OPEN_ANCHOR_SCRIPTSIGS)
->open_anchor_scriptsigs;
pkt = leak_anchor_sigs_and_pretend_we_didnt_pkt(ctx, s);
if (!write_all(STDOUT_FILENO, pkt,

76
lightning.pb-c.c

@ -351,47 +351,47 @@ void open_commit_sig__free_unpacked
assert(message->base.descriptor == &open_commit_sig__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void open_anchor_sig__init
(OpenAnchorSig *message)
void open_anchor_scriptsigs__init
(OpenAnchorScriptsigs *message)
{
static OpenAnchorSig init_value = OPEN_ANCHOR_SIG__INIT;
static OpenAnchorScriptsigs init_value = OPEN_ANCHOR_SCRIPTSIGS__INIT;
*message = init_value;
}
size_t open_anchor_sig__get_packed_size
(const OpenAnchorSig *message)
size_t open_anchor_scriptsigs__get_packed_size
(const OpenAnchorScriptsigs *message)
{
assert(message->base.descriptor == &open_anchor_sig__descriptor);
assert(message->base.descriptor == &open_anchor_scriptsigs__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t open_anchor_sig__pack
(const OpenAnchorSig *message,
size_t open_anchor_scriptsigs__pack
(const OpenAnchorScriptsigs *message,
uint8_t *out)
{
assert(message->base.descriptor == &open_anchor_sig__descriptor);
assert(message->base.descriptor == &open_anchor_scriptsigs__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t open_anchor_sig__pack_to_buffer
(const OpenAnchorSig *message,
size_t open_anchor_scriptsigs__pack_to_buffer
(const OpenAnchorScriptsigs *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &open_anchor_sig__descriptor);
assert(message->base.descriptor == &open_anchor_scriptsigs__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
OpenAnchorSig *
open_anchor_sig__unpack
OpenAnchorScriptsigs *
open_anchor_scriptsigs__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (OpenAnchorSig *)
protobuf_c_message_unpack (&open_anchor_sig__descriptor,
return (OpenAnchorScriptsigs *)
protobuf_c_message_unpack (&open_anchor_scriptsigs__descriptor,
allocator, len, data);
}
void open_anchor_sig__free_unpacked
(OpenAnchorSig *message,
void open_anchor_scriptsigs__free_unpacked
(OpenAnchorScriptsigs *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &open_anchor_sig__descriptor);
assert(message->base.descriptor == &open_anchor_scriptsigs__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void leak_anchor_sigs_and_pretend_we_didnt__init
@ -1629,42 +1629,42 @@ const ProtobufCMessageDescriptor open_commit_sig__descriptor =
(ProtobufCMessageInit) open_commit_sig__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor open_anchor_sig__field_descriptors[1] =
static const ProtobufCFieldDescriptor open_anchor_scriptsigs__field_descriptors[1] =
{
{
"script",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_BYTES,
offsetof(OpenAnchorSig, n_script),
offsetof(OpenAnchorSig, script),
offsetof(OpenAnchorScriptsigs, n_script),
offsetof(OpenAnchorScriptsigs, script),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned open_anchor_sig__field_indices_by_name[] = {
static const unsigned open_anchor_scriptsigs__field_indices_by_name[] = {
0, /* field[0] = script */
};
static const ProtobufCIntRange open_anchor_sig__number_ranges[1 + 1] =
static const ProtobufCIntRange open_anchor_scriptsigs__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor open_anchor_sig__descriptor =
const ProtobufCMessageDescriptor open_anchor_scriptsigs__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"open_anchor_sig",
"OpenAnchorSig",
"OpenAnchorSig",
"open_anchor_scriptsigs",
"OpenAnchorScriptsigs",
"OpenAnchorScriptsigs",
"",
sizeof(OpenAnchorSig),
sizeof(OpenAnchorScriptsigs),
1,
open_anchor_sig__field_descriptors,
open_anchor_sig__field_indices_by_name,
1, open_anchor_sig__number_ranges,
(ProtobufCMessageInit) open_anchor_sig__init,
open_anchor_scriptsigs__field_descriptors,
open_anchor_scriptsigs__field_indices_by_name,
1, open_anchor_scriptsigs__number_ranges,
(ProtobufCMessageInit) open_anchor_scriptsigs__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor leak_anchor_sigs_and_pretend_we_didnt__field_descriptors[1] =
@ -1676,7 +1676,7 @@ static const ProtobufCFieldDescriptor leak_anchor_sigs_and_pretend_we_didnt__fie
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(LeakAnchorSigsAndPretendWeDidnt, sigs),
&open_anchor_sig__descriptor,
&open_anchor_scriptsigs__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
@ -2289,13 +2289,13 @@ static const ProtobufCFieldDescriptor pkt__field_descriptors[15] =
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"open_anchor_sig",
"open_anchor_scriptsigs",
203,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Pkt, pkt_case),
offsetof(Pkt, open_anchor_sig),
&open_anchor_sig__descriptor,
offsetof(Pkt, open_anchor_scriptsigs),
&open_anchor_scriptsigs__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
@ -2419,7 +2419,7 @@ static const unsigned pkt__field_indices_by_name[] = {
11, /* field[11] = new_anchor_complete */
7, /* field[7] = omg_fail */
3, /* field[3] = open */
5, /* field[5] = open_anchor_sig */
5, /* field[5] = open_anchor_scriptsigs */
4, /* field[4] = open_commit_sig */
6, /* field[6] = open_complete */
0, /* field[0] = update */

46
lightning.pb-c.h

@ -23,7 +23,7 @@ typedef struct _BitcoinPubkey BitcoinPubkey;
typedef struct _Anchor Anchor;
typedef struct _OpenChannel OpenChannel;
typedef struct _OpenCommitSig OpenCommitSig;
typedef struct _OpenAnchorSig OpenAnchorSig;
typedef struct _OpenAnchorScriptsigs OpenAnchorScriptsigs;
typedef struct _LeakAnchorSigsAndPretendWeDidnt LeakAnchorSigsAndPretendWeDidnt;
typedef struct _OpenComplete OpenComplete;
typedef struct _Update Update;
@ -229,14 +229,14 @@ struct _OpenCommitSig
/*
* Supply ScriptSig for each anchor tx inputs.
*/
struct _OpenAnchorSig
struct _OpenAnchorScriptsigs
{
ProtobufCMessage base;
size_t n_script;
ProtobufCBinaryData *script;
};
#define OPEN_ANCHOR_SIG__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&open_anchor_sig__descriptor) \
#define OPEN_ANCHOR_SCRIPTSIGS__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&open_anchor_scriptsigs__descriptor) \
, 0,NULL }
@ -252,7 +252,7 @@ struct _OpenAnchorSig
struct _LeakAnchorSigsAndPretendWeDidnt
{
ProtobufCMessage base;
OpenAnchorSig *sigs;
OpenAnchorScriptsigs *sigs;
};
#define LEAK_ANCHOR_SIGS_AND_PRETEND_WE_DIDNT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&leak_anchor_sigs_and_pretend_we_didnt__descriptor) \
@ -471,7 +471,7 @@ typedef enum {
PKT__PKT_OPEN = 201,
PKT__PKT_OMG_FAIL = 205,
PKT__PKT_OPEN_COMMIT_SIG = 202,
PKT__PKT_OPEN_ANCHOR_SIG = 203,
PKT__PKT_OPEN_ANCHOR_SCRIPTSIGS = 203,
PKT__PKT_OPEN_COMPLETE = 204,
PKT__PKT_UPDATE = 1,
PKT__PKT_UPDATE_ACCEPT = 2,
@ -499,7 +499,7 @@ struct _Pkt
OpenChannel *open;
LeakAnchorSigsAndPretendWeDidnt *omg_fail;
OpenCommitSig *open_commit_sig;
OpenAnchorSig *open_anchor_sig;
OpenAnchorScriptsigs *open_anchor_scriptsigs;
OpenComplete *open_complete;
/*
* Updating (most common)
@ -682,24 +682,24 @@ OpenCommitSig *
void open_commit_sig__free_unpacked
(OpenCommitSig *message,
ProtobufCAllocator *allocator);
/* OpenAnchorSig methods */
void open_anchor_sig__init
(OpenAnchorSig *message);
size_t open_anchor_sig__get_packed_size
(const OpenAnchorSig *message);
size_t open_anchor_sig__pack
(const OpenAnchorSig *message,
/* OpenAnchorScriptsigs methods */
void open_anchor_scriptsigs__init
(OpenAnchorScriptsigs *message);
size_t open_anchor_scriptsigs__get_packed_size
(const OpenAnchorScriptsigs *message);
size_t open_anchor_scriptsigs__pack
(const OpenAnchorScriptsigs *message,
uint8_t *out);
size_t open_anchor_sig__pack_to_buffer
(const OpenAnchorSig *message,
size_t open_anchor_scriptsigs__pack_to_buffer
(const OpenAnchorScriptsigs *message,
ProtobufCBuffer *buffer);
OpenAnchorSig *
open_anchor_sig__unpack
OpenAnchorScriptsigs *
open_anchor_scriptsigs__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void open_anchor_sig__free_unpacked
(OpenAnchorSig *message,
void open_anchor_scriptsigs__free_unpacked
(OpenAnchorScriptsigs *message,
ProtobufCAllocator *allocator);
/* LeakAnchorSigsAndPretendWeDidnt methods */
void leak_anchor_sigs_and_pretend_we_didnt__init
@ -993,8 +993,8 @@ typedef void (*OpenChannel_Closure)
typedef void (*OpenCommitSig_Closure)
(const OpenCommitSig *message,
void *closure_data);
typedef void (*OpenAnchorSig_Closure)
(const OpenAnchorSig *message,
typedef void (*OpenAnchorScriptsigs_Closure)
(const OpenAnchorScriptsigs *message,
void *closure_data);
typedef void (*LeakAnchorSigsAndPretendWeDidnt_Closure)
(const LeakAnchorSigsAndPretendWeDidnt *message,
@ -1052,7 +1052,7 @@ extern const ProtobufCMessageDescriptor bitcoin_pubkey__descriptor;
extern const ProtobufCMessageDescriptor anchor__descriptor;
extern const ProtobufCMessageDescriptor open_channel__descriptor;
extern const ProtobufCMessageDescriptor open_commit_sig__descriptor;
extern const ProtobufCMessageDescriptor open_anchor_sig__descriptor;
extern const ProtobufCMessageDescriptor open_anchor_scriptsigs__descriptor;
extern const ProtobufCMessageDescriptor leak_anchor_sigs_and_pretend_we_didnt__descriptor;
extern const ProtobufCMessageDescriptor open_complete__descriptor;
extern const ProtobufCMessageDescriptor update__descriptor;

6
lightning.proto

@ -92,7 +92,7 @@ message open_commit_sig {
}
// Supply ScriptSig for each anchor tx inputs.
message open_anchor_sig {
message open_anchor_scriptsigs {
repeated bytes script = 1;
}
@ -105,7 +105,7 @@ message open_anchor_sig {
// malleability anyway). So for testing, we send the scriptsigs for the
// anchor transaction's inputs immediately.
message leak_anchor_sigs_and_pretend_we_didnt {
required open_anchor_sig sigs = 1;
required open_anchor_scriptsigs sigs = 1;
}
// Indicates we've seen transaction reach min-depth.
@ -197,7 +197,7 @@ message pkt {
open_channel open = 201;
leak_anchor_sigs_and_pretend_we_didnt omg_fail = 205;
open_commit_sig open_commit_sig = 202;
open_anchor_sig open_anchor_sig = 203;
open_anchor_scriptsigs open_anchor_scriptsigs = 203;
open_complete open_complete = 204;
// Updating (most common)
update update = 1;

4
open-anchor-sig.c → open-anchor-scriptsigs.c

@ -1,6 +1,6 @@
/* My example:
* ./open-anchor-sig A-open.pb B-open.pb cUjoranStkpgTRumAJZNiNEkknJv5UA7wzW1nZ7aPsm9ZWjkxypZ > A-anchor-scriptsigs.pb
* ./open-anchor-sig B-open.pb A-open.pb cNggXygY8fPHWHEdoDqRa6xALau8gVMLq6q6vzMs2eNegLrJGNAW > B-anchor-scriptsigs.pb
* ./open-anchor-scriptsigs A-open.pb B-open.pb cUjoranStkpgTRumAJZNiNEkknJv5UA7wzW1nZ7aPsm9ZWjkxypZ > A-anchor-scriptsigs.pb
* ./open-anchor-scriptsigs B-open.pb A-open.pb cNggXygY8fPHWHEdoDqRa6xALau8gVMLq6q6vzMs2eNegLrJGNAW > B-anchor-scriptsigs.pb
*/
#include <ccan/err/err.h>
#include <ccan/opt/opt.h>

6
pkt.c

@ -108,7 +108,7 @@ Pkt *pkt_from_file(const char *filename, Pkt__PktCase expect)
struct pkt *open_anchor_sig_pkt(const tal_t *ctx, u8 **sigs, size_t num_sigs)
{
OpenAnchorSig o = OPEN_ANCHOR_SIG__INIT;
OpenAnchorScriptsigs o = OPEN_ANCHOR_SCRIPTSIGS__INIT;
size_t i;
o.n_script = num_sigs;
@ -118,11 +118,11 @@ struct pkt *open_anchor_sig_pkt(const tal_t *ctx, u8 **sigs, size_t num_sigs)
o.script[i].len = tal_count(sigs[i]);
}
return to_pkt(ctx, PKT__PKT_OPEN_ANCHOR_SIG, &o);
return to_pkt(ctx, PKT__PKT_OPEN_ANCHOR_SCRIPTSIGS, &o);
}
struct pkt *leak_anchor_sigs_and_pretend_we_didnt_pkt(const tal_t *ctx,
OpenAnchorSig *s)
OpenAnchorScriptsigs *s)
{
LeakAnchorSigsAndPretendWeDidnt omg_fail
= LEAK_ANCHOR_SIGS_AND_PRETEND_WE_DIDNT__INIT;

2
pkt.h

@ -56,7 +56,7 @@ struct pkt *open_anchor_sig_pkt(const tal_t *ctx, u8 **sigs, size_t num_sigs);
* @s: OpenAnchorSig.
*/
struct pkt *leak_anchor_sigs_and_pretend_we_didnt_pkt(const tal_t *ctx,
OpenAnchorSig *s);
OpenAnchorScriptsigs *s);
/**

Loading…
Cancel
Save