bitcoin: create new wrapper type bitcoin_blkid, log backward endianness.

It's just a sha256_double, but importantly when we convert it to a
string (in type_to_string, which is used in logging) we use
bitcoin_blkid_to_hex() so it's reversed as people expect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-12-18 17:14:10 +10:30
parent 0237e0b28c
commit 810abb6b21
27 changed files with 92 additions and 73 deletions

View File

@@ -2,6 +2,7 @@
#include "bitcoin/pullpush.h" #include "bitcoin/pullpush.h"
#include "bitcoin/tx.h" #include "bitcoin/tx.h"
#include <ccan/str/hex/hex.h> #include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>
/* Encoding is <blockhdr> <varint-num-txs> <tx>... */ /* Encoding is <blockhdr> <varint-num-txs> <tx>... */
struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx, struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx,
@@ -38,20 +39,21 @@ struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx,
return b; return b;
} }
/* We do the same hex-reversing crud as txids. */
bool bitcoin_blkid_from_hex(const char *hexstr, size_t hexstr_len, bool bitcoin_blkid_from_hex(const char *hexstr, size_t hexstr_len,
struct sha256_double *blockid) struct bitcoin_blkid *blockid)
{ {
struct bitcoin_txid fake_txid; struct bitcoin_txid fake_txid;
if (!bitcoin_txid_from_hex(hexstr, hexstr_len, &fake_txid)) if (!bitcoin_txid_from_hex(hexstr, hexstr_len, &fake_txid))
return false; return false;
*blockid = fake_txid.shad; blockid->shad = fake_txid.shad;
return true; return true;
} }
bool bitcoin_blkid_to_hex(const struct sha256_double *blockid, bool bitcoin_blkid_to_hex(const struct bitcoin_blkid *blockid,
char *hexstr, size_t hexstr_len) char *hexstr, size_t hexstr_len)
{ {
struct bitcoin_txid fake_txid; struct bitcoin_txid fake_txid;
fake_txid.shad = *blockid; fake_txid.shad = blockid->shad;
return bitcoin_txid_to_hex(&fake_txid, hexstr, hexstr_len); return bitcoin_txid_to_hex(&fake_txid, hexstr, hexstr_len);
} }

View File

@@ -7,9 +7,13 @@
#include <ccan/tal/tal.h> #include <ccan/tal/tal.h>
#include <stdbool.h> #include <stdbool.h>
struct bitcoin_blkid {
struct sha256_double shad;
};
struct bitcoin_block_hdr { struct bitcoin_block_hdr {
le32 version; le32 version;
struct sha256_double prev_hash; struct bitcoin_blkid prev_hash;
struct sha256_double merkle_hash; struct sha256_double merkle_hash;
le32 timestamp; le32 timestamp;
le32 target; le32 target;
@@ -27,9 +31,9 @@ struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx,
/* Parse hex string to get blockid (reversed, a-la bitcoind). */ /* Parse hex string to get blockid (reversed, a-la bitcoind). */
bool bitcoin_blkid_from_hex(const char *hexstr, size_t hexstr_len, bool bitcoin_blkid_from_hex(const char *hexstr, size_t hexstr_len,
struct sha256_double *blockid); struct bitcoin_blkid *blockid);
/* Get hex string of blockid (reversed, a-la bitcoind). */ /* Get hex string of blockid (reversed, a-la bitcoind). */
bool bitcoin_blkid_to_hex(const struct sha256_double *blockid, bool bitcoin_blkid_to_hex(const struct bitcoin_blkid *blockid,
char *hexstr, size_t hexstr_len); char *hexstr, size_t hexstr_len);
#endif /* LIGHTNING_BITCOIN_BLOCK_H */ #endif /* LIGHTNING_BITCOIN_BLOCK_H */

View File

@@ -7,7 +7,7 @@ const struct chainparams networks[] = {
{.index = 0, {.index = 0,
.network_name = "bitcoin", .network_name = "bitcoin",
.bip173_name = "bc", .bip173_name = "bc",
.genesis_blockhash = {{.u.u8 = {0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00}}}, .genesis_blockhash = {{{.u.u8 = {0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00}}}},
.rpc_port = 8332, .rpc_port = 8332,
.cli = "bitcoin-cli", .cli = "bitcoin-cli",
.cli_args = NULL, .cli_args = NULL,
@@ -16,7 +16,7 @@ const struct chainparams networks[] = {
{.index = 1, {.index = 1,
.network_name = "regtest", .network_name = "regtest",
.bip173_name = "tb", .bip173_name = "tb",
.genesis_blockhash = {{.u.u8 = {0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b, 0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb, 0x5b, 0xbf, 0x28, 0xc3, 0x4f, 0x3a, 0x5e, 0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f}}}, .genesis_blockhash = {{{.u.u8 = {0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b, 0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb, 0x5b, 0xbf, 0x28, 0xc3, 0x4f, 0x3a, 0x5e, 0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f}}}},
.rpc_port = 18332, .rpc_port = 18332,
.cli = "bitcoin-cli", .cli = "bitcoin-cli",
.cli_args = "-regtest", .cli_args = "-regtest",
@@ -25,7 +25,7 @@ const struct chainparams networks[] = {
{.index = 2, {.index = 2,
.network_name = "testnet", .network_name = "testnet",
.bip173_name = "tb", .bip173_name = "tb",
.genesis_blockhash = {{.u.u8 = {0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95, 0x71, 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce, 0xc3, 0xae, 0xba, 0x79, 0x97, 0x20, 0x84, 0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00}}}, .genesis_blockhash = {{{.u.u8 = {0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95, 0x71, 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce, 0xc3, 0xae, 0xba, 0x79, 0x97, 0x20, 0x84, 0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00}}}},
.rpc_port = 18332, .rpc_port = 18332,
.cli = "bitcoin-cli", .cli = "bitcoin-cli",
.cli_args = "-testnet", .cli_args = "-testnet",
@@ -34,7 +34,7 @@ const struct chainparams networks[] = {
{.index = 3, {.index = 3,
.network_name = "litecoin", .network_name = "litecoin",
.bip173_name = "ltc", .bip173_name = "ltc",
.genesis_blockhash = {{.u.u8 = {0xe2, 0xbf, 0x04, 0x7e, 0x7e, 0x5a, 0x19, 0x1a, 0xa4, 0xef, 0x34, 0xd3, 0x14, 0x97, 0x9d, 0xc9, 0x98, 0x6e, 0x0f, 0x19, 0x25, 0x1e, 0xda, 0xba, 0x59, 0x40, 0xfd, 0x1f, 0xe3, 0x65, 0xa7, 0x12 }}}, .genesis_blockhash = {{{.u.u8 = {0xe2, 0xbf, 0x04, 0x7e, 0x7e, 0x5a, 0x19, 0x1a, 0xa4, 0xef, 0x34, 0xd3, 0x14, 0x97, 0x9d, 0xc9, 0x98, 0x6e, 0x0f, 0x19, 0x25, 0x1e, 0xda, 0xba, 0x59, 0x40, 0xfd, 0x1f, 0xe3, 0x65, 0xa7, 0x12 }}}},
.rpc_port = 18332, .rpc_port = 18332,
.cli = "litecoin-cli", .cli = "litecoin-cli",
.cli_args = "", .cli_args = "",

View File

@@ -2,7 +2,7 @@
#define LIGHTNING_BITCOIN_CHAINPARAMS_H #define LIGHTNING_BITCOIN_CHAINPARAMS_H
#include "config.h" #include "config.h"
#include <bitcoin/shadouble.h> #include <bitcoin/block.h>
#include <ccan/short_types/short_types.h> #include <ccan/short_types/short_types.h>
#include <stdbool.h> #include <stdbool.h>
@@ -10,7 +10,7 @@ struct chainparams {
const int index; const int index;
const char *network_name; const char *network_name;
const char *bip173_name; const char *bip173_name;
const struct sha256_double genesis_blockhash; const struct bitcoin_blkid genesis_blockhash;
const int rpc_port; const int rpc_port;
const char *cli; const char *cli;
const char *cli_args; const char *cli_args;

View File

@@ -1,6 +1,5 @@
#include "shadouble.h" #include "shadouble.h"
#include <ccan/mem/mem.h> #include <ccan/mem/mem.h>
#include <common/type_to_string.h>
void sha256_double(struct sha256_double *shadouble, const void *p, size_t len) void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
{ {
@@ -13,5 +12,3 @@ void sha256_double_done(struct sha256_ctx *shactx, struct sha256_double *res)
sha256_done(shactx, &res->sha); sha256_done(shactx, &res->sha);
sha256(&res->sha, &res->sha, sizeof(res->sha)); sha256(&res->sha, &res->sha, sizeof(res->sha));
} }
REGISTER_TYPE_TO_HEXSTR(sha256_double);

View File

@@ -101,7 +101,7 @@ struct peer {
*/ */
u64 htlc_id; u64 htlc_id;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
struct channel_id channel_id; struct channel_id channel_id;
struct channel *channel; struct channel *channel;

View File

@@ -6,7 +6,7 @@ channel_normal_operation,11001
# Begin! (passes gossipd-client fd) # Begin! (passes gossipd-client fd)
channel_init,1000 channel_init,1000
channel_init,,chain_hash,struct sha256_double channel_init,,chain_hash,struct bitcoin_blkid
channel_init,,funding_txid,struct bitcoin_txid channel_init,,funding_txid,struct bitcoin_txid
channel_init,,funding_txout,u16 channel_init,,funding_txout,u16
channel_init,,funding_satoshi,u64 channel_init,,funding_satoshi,u64
1 # Received and sent funding_locked
6 channel_init,1000
7 channel_init,,chain_hash,struct sha256_double channel_init,,chain_hash,struct bitcoin_blkid
8 channel_init,,funding_txid,struct bitcoin_txid
9 channel_init,,funding_txout,u16
10 channel_init,,funding_satoshi,u64
11 channel_init,,our_config,struct channel_config
12 channel_init,,their_config,struct channel_config

View File

@@ -8,8 +8,8 @@
/* This must match the type_to_string_ cases. */ /* This must match the type_to_string_ cases. */
union printable_types { union printable_types {
const struct pubkey *pubkey; const struct pubkey *pubkey;
const struct sha256_double *sha256_double;
const struct bitcoin_txid *bitcoin_txid; const struct bitcoin_txid *bitcoin_txid;
const struct bitcoin_blkid *bitcoin_blkid;
const struct sha256 *sha256; const struct sha256 *sha256;
const struct ripemd160 *ripemd160; const struct ripemd160 *ripemd160;
const struct rel_locktime *rel_locktime; const struct rel_locktime *rel_locktime;

View File

@@ -742,7 +742,7 @@ static void handle_local_add_channel(struct peer *peer, u8 *msg)
{ {
struct routing_state *rstate = peer->daemon->rstate; struct routing_state *rstate = peer->daemon->rstate;
struct short_channel_id scid; struct short_channel_id scid;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
struct pubkey remote_node_id; struct pubkey remote_node_id;
u16 flags, cltv_expiry_delta, direction; u16 flags, cltv_expiry_delta, direction;
u32 fee_base_msat, fee_proportional_millionths; u32 fee_base_msat, fee_proportional_millionths;
@@ -759,7 +759,8 @@ static void handle_local_add_channel(struct peer *peer, u8 *msg)
if (!structeq(&chain_hash, &rstate->chain_hash)) { if (!structeq(&chain_hash, &rstate->chain_hash)) {
status_trace("Received channel_announcement for unknown chain %s", status_trace("Received channel_announcement for unknown chain %s",
type_to_string(msg, struct sha256_double,&chain_hash)); type_to_string(msg, struct bitcoin_blkid,
&chain_hash));
return; return;
} }
@@ -1288,7 +1289,7 @@ static struct io_plan *gossip_init(struct daemon_conn *master,
struct daemon *daemon, struct daemon *daemon,
const u8 *msg) const u8 *msg)
{ {
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
u16 port; u16 port;
if (!fromwire_gossipctl_init(daemon, msg, NULL, if (!fromwire_gossipctl_init(daemon, msg, NULL,

View File

@@ -4,7 +4,7 @@
# Initialize the gossip daemon. # Initialize the gossip daemon.
gossipctl_init,3000 gossipctl_init,3000
gossipctl_init,,broadcast_interval,u32 gossipctl_init,,broadcast_interval,u32
gossipctl_init,,chain_hash,struct sha256_double gossipctl_init,,chain_hash,struct bitcoin_blkid
gossipctl_init,,id,struct pubkey gossipctl_init,,id,struct pubkey
# If non-zero, port to listen on. # If non-zero, port to listen on.
gossipctl_init,,port,u16 gossipctl_init,,port,u16
@@ -150,7 +150,7 @@ gossip_send_gossip,,gossip,len*u8
# we can use it already. # we can use it already.
gossip_local_add_channel,3017 gossip_local_add_channel,3017
gossip_local_add_channel,,short_channel_id,struct short_channel_id gossip_local_add_channel,,short_channel_id,struct short_channel_id
gossip_local_add_channel,,chain_hash,struct sha256_double gossip_local_add_channel,,chain_hash,struct bitcoin_blkid
gossip_local_add_channel,,remote_node_id,struct pubkey gossip_local_add_channel,,remote_node_id,struct pubkey
gossip_local_add_channel,,flags,u16 gossip_local_add_channel,,flags,u16
gossip_local_add_channel,,cltv_expiry_delta,u16 gossip_local_add_channel,,cltv_expiry_delta,u16
1 #include <common/cryptomsg.h>
4 gossipctl_init,3000
5 gossipctl_init,,broadcast_interval,u32
6 gossipctl_init,,chain_hash,struct sha256_double gossipctl_init,,chain_hash,struct bitcoin_blkid
7 gossipctl_init,,id,struct pubkey
8 # If non-zero, port to listen on.
9 gossipctl_init,,port,u16
10 gossipctl_init,,gflen,u16
150
151
152
153
154
155
156

View File

@@ -35,7 +35,7 @@ static struct node_map *empty_node_map(const tal_t *ctx)
} }
struct routing_state *new_routing_state(const tal_t *ctx, struct routing_state *new_routing_state(const tal_t *ctx,
const struct sha256_double *chain_hash, const struct bitcoin_blkid *chain_hash,
const struct pubkey *local_id) const struct pubkey *local_id)
{ {
struct routing_state *rstate = tal(ctx, struct routing_state); struct routing_state *rstate = tal(ctx, struct routing_state);
@@ -503,7 +503,7 @@ bool handle_channel_announcement(
struct pubkey node_id_2; struct pubkey node_id_2;
struct pubkey bitcoin_key_1; struct pubkey bitcoin_key_1;
struct pubkey bitcoin_key_2; struct pubkey bitcoin_key_2;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
struct node_connection *c0, *c1; struct node_connection *c0, *c1;
const tal_t *tmpctx = tal_tmpctx(rstate); const tal_t *tmpctx = tal_tmpctx(rstate);
u8 *features; u8 *features;
@@ -531,7 +531,7 @@ bool handle_channel_announcement(
if (!structeq(&chain_hash, &rstate->chain_hash)) { if (!structeq(&chain_hash, &rstate->chain_hash)) {
status_trace("Received channel_announcement for unknown chain" status_trace("Received channel_announcement for unknown chain"
" %s", " %s",
type_to_string(tmpctx, struct sha256_double, type_to_string(tmpctx, struct bitcoin_blkid,
&chain_hash)); &chain_hash));
tal_free(tmpctx); tal_free(tmpctx);
return false; return false;
@@ -603,7 +603,7 @@ void handle_channel_update(struct routing_state *rstate, const u8 *update)
u32 fee_base_msat; u32 fee_base_msat;
u32 fee_proportional_millionths; u32 fee_proportional_millionths;
const tal_t *tmpctx = tal_tmpctx(rstate); const tal_t *tmpctx = tal_tmpctx(rstate);
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
size_t len = tal_len(update); size_t len = tal_len(update);
serialized = tal_dup_arr(tmpctx, u8, update, len, 0); serialized = tal_dup_arr(tmpctx, u8, update, len, 0);
@@ -623,7 +623,7 @@ void handle_channel_update(struct routing_state *rstate, const u8 *update)
* specified chain. */ * specified chain. */
if (!structeq(&chain_hash, &rstate->chain_hash)) { if (!structeq(&chain_hash, &rstate->chain_hash)) {
status_trace("Received channel_update for unknown chain %s", status_trace("Received channel_update for unknown chain %s",
type_to_string(tmpctx, struct sha256_double, type_to_string(tmpctx, struct bitcoin_blkid,
&chain_hash)); &chain_hash));
tal_free(tmpctx); tal_free(tmpctx);
return; return;

View File

@@ -82,7 +82,7 @@ struct routing_state {
struct broadcast_state *broadcasts; struct broadcast_state *broadcasts;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
/* Our own ID so we can identify local channels */ /* Our own ID so we can identify local channels */
struct pubkey local_id; struct pubkey local_id;
@@ -96,7 +96,7 @@ struct route_hop {
}; };
struct routing_state *new_routing_state(const tal_t *ctx, struct routing_state *new_routing_state(const tal_t *ctx,
const struct sha256_double *chain_hash, const struct bitcoin_blkid *chain_hash,
const struct pubkey *local_id); const struct pubkey *local_id);
/* Add a connection to the routing table, but do not mark it as usable /* Add a connection to the routing table, but do not mark it as usable

View File

@@ -49,10 +49,10 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
/* AUTOGENERATED MOCKS START */ /* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_channel_announcement */ /* Generated stub for fromwire_channel_announcement */
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct sha256_double *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED) bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }
/* Generated stub for fromwire_channel_update */ /* Generated stub for fromwire_channel_update */
bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct sha256_double *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED) bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_node_announcement */ /* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED) bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
@@ -151,7 +151,7 @@ static void run(const char *name)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
static const struct sha256_double zerohash; static const struct bitcoin_blkid zerohash;
const tal_t *ctx = trc = tal_tmpctx(NULL); const tal_t *ctx = trc = tal_tmpctx(NULL);
struct routing_state *rstate; struct routing_state *rstate;
size_t num_nodes = 100, num_runs = 1; size_t num_nodes = 100, num_runs = 1;

View File

@@ -20,10 +20,10 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
/* AUTOGENERATED MOCKS START */ /* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_channel_announcement */ /* Generated stub for fromwire_channel_announcement */
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct sha256_double *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED) bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }
/* Generated stub for fromwire_channel_update */ /* Generated stub for fromwire_channel_update */
bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct sha256_double *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED) bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_node_announcement */ /* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED) bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
@@ -57,7 +57,7 @@ const void *trc;
int main(void) int main(void)
{ {
static const struct sha256_double zerohash; static const struct bitcoin_blkid zerohash;
const tal_t *ctx = trc = tal_tmpctx(NULL); const tal_t *ctx = trc = tal_tmpctx(NULL);
struct node_connection *nc; struct node_connection *nc;
struct routing_state *rstate; struct routing_state *rstate;

View File

@@ -13,10 +13,10 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
/* AUTOGENERATED MOCKS START */ /* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_channel_announcement */ /* Generated stub for fromwire_channel_announcement */
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct sha256_double *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED) bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }
/* Generated stub for fromwire_channel_update */ /* Generated stub for fromwire_channel_update */
bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct sha256_double *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED) bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_node_announcement */ /* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED) bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
@@ -67,7 +67,7 @@ static struct node_connection *add_connection(struct routing_state *rstate,
int main(void) int main(void)
{ {
static const struct sha256_double zerohash; static const struct bitcoin_blkid zerohash;
const tal_t *ctx = trc = tal_tmpctx(NULL); const tal_t *ctx = trc = tal_tmpctx(NULL);
struct node_connection *nc; struct node_connection *nc;
struct routing_state *rstate; struct routing_state *rstate;

View File

@@ -196,7 +196,7 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
u32 timestamp, fee_base_msat, fee_proportional_mill; u32 timestamp, fee_base_msat, fee_proportional_mill;
u64 htlc_minimum_msat; u64 htlc_minimum_msat;
u16 flags, cltv_expiry_delta; u16 flags, cltv_expiry_delta;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
u8 *cu; u8 *cu;
if (!fromwire_hsm_cupdate_sig_req(tmpctx, dc->msg_in, NULL, &cu)) { if (!fromwire_hsm_cupdate_sig_req(tmpctx, dc->msg_in, NULL, &cu)) {

View File

@@ -360,9 +360,9 @@ static void process_chaintips(struct bitcoin_cli *bcli)
const jsmntok_t *tokens, *t, *end; const jsmntok_t *tokens, *t, *end;
bool valid; bool valid;
size_t i; size_t i;
struct sha256_double tip; struct bitcoin_blkid tip;
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
struct sha256_double *tipid, struct bitcoin_blkid *tipid,
void *arg) = bcli->cb; void *arg) = bcli->cb;
tokens = json_parse_input(bcli->output, bcli->output_bytes, &valid); tokens = json_parse_input(bcli->output, bcli->output_bytes, &valid);
@@ -418,7 +418,7 @@ static void process_chaintips(struct bitcoin_cli *bcli)
void bitcoind_get_chaintip_(struct bitcoind *bitcoind, void bitcoind_get_chaintip_(struct bitcoind *bitcoind,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
const struct sha256_double *tipid, const struct bitcoin_blkid *tipid,
void *arg), void *arg),
void *arg) void *arg)
{ {
@@ -444,7 +444,7 @@ static void process_rawblock(struct bitcoin_cli *bcli)
} }
void bitcoind_getrawblock_(struct bitcoind *bitcoind, void bitcoind_getrawblock_(struct bitcoind *bitcoind,
const struct sha256_double *blockid, const struct bitcoin_blkid *blockid,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
struct bitcoin_block *blk, struct bitcoin_block *blk,
void *arg), void *arg),
@@ -486,9 +486,9 @@ void bitcoind_getblockcount_(struct bitcoind *bitcoind,
static void process_getblockhash(struct bitcoin_cli *bcli) static void process_getblockhash(struct bitcoin_cli *bcli)
{ {
struct sha256_double blkid; struct bitcoin_blkid blkid;
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
const struct sha256_double *blkid, const struct bitcoin_blkid *blkid,
void *arg) = bcli->cb; void *arg) = bcli->cb;
if (bcli->output_bytes == 0 if (bcli->output_bytes == 0
@@ -504,7 +504,7 @@ static void process_getblockhash(struct bitcoin_cli *bcli)
void bitcoind_getblockhash_(struct bitcoind *bitcoind, void bitcoind_getblockhash_(struct bitcoind *bitcoind,
u32 height, u32 height,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
const struct sha256_double *blkid, const struct bitcoin_blkid *blkid,
void *arg), void *arg),
void *arg) void *arg)
{ {

View File

@@ -9,7 +9,7 @@
#include <ccan/typesafe_cb/typesafe_cb.h> #include <ccan/typesafe_cb/typesafe_cb.h>
#include <stdbool.h> #include <stdbool.h>
struct sha256_double; struct bitcoin_blkid;
struct lightningd; struct lightningd;
struct ripemd160; struct ripemd160;
struct bitcoin_tx; struct bitcoin_tx;
@@ -86,7 +86,7 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
void bitcoind_get_chaintip_(struct bitcoind *bitcoind, void bitcoind_get_chaintip_(struct bitcoind *bitcoind,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
const struct sha256_double *tipid, const struct bitcoin_blkid *tipid,
void *arg), void *arg),
void *arg); void *arg);
@@ -95,7 +95,7 @@ void bitcoind_get_chaintip_(struct bitcoind *bitcoind,
typesafe_cb_preargs(void, void *, \ typesafe_cb_preargs(void, void *, \
(cb), (arg), \ (cb), (arg), \
struct bitcoind *, \ struct bitcoind *, \
const struct sha256_double *), \ const struct bitcoin_blkid *), \
(arg)) (arg))
void bitcoind_getblockcount_(struct bitcoind *bitcoind, void bitcoind_getblockcount_(struct bitcoind *bitcoind,
@@ -115,7 +115,7 @@ void bitcoind_getblockcount_(struct bitcoind *bitcoind,
void bitcoind_getblockhash_(struct bitcoind *bitcoind, void bitcoind_getblockhash_(struct bitcoind *bitcoind,
u32 height, u32 height,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
const struct sha256_double *blkid, const struct bitcoin_blkid *blkid,
void *arg), void *arg),
void *arg); void *arg);
#define bitcoind_getblockhash(bitcoind_, height, cb, arg) \ #define bitcoind_getblockhash(bitcoind_, height, cb, arg) \
@@ -124,11 +124,11 @@ void bitcoind_getblockhash_(struct bitcoind *bitcoind,
typesafe_cb_preargs(void, void *, \ typesafe_cb_preargs(void, void *, \
(cb), (arg), \ (cb), (arg), \
struct bitcoind *, \ struct bitcoind *, \
const struct sha256_double *), \ const struct bitcoin_blkid *), \
(arg)) (arg))
void bitcoind_getrawblock_(struct bitcoind *bitcoind, void bitcoind_getrawblock_(struct bitcoind *bitcoind,
const struct sha256_double *blockid, const struct bitcoin_blkid *blockid,
void (*cb)(struct bitcoind *bitcoind, void (*cb)(struct bitcoind *bitcoind,
struct bitcoin_block *blk, struct bitcoin_block *blk,
void *arg), void *arg),

View File

@@ -381,9 +381,9 @@ static struct block *new_block(struct chain_topology *topo,
{ {
struct block *b = tal(topo, struct block); struct block *b = tal(topo, struct block);
sha256_double(&b->blkid, &blk->hdr, sizeof(blk->hdr)); sha256_double(&b->blkid.shad, &blk->hdr, sizeof(blk->hdr));
log_debug(topo->log, "Adding block %s", log_debug(topo->log, "Adding block %s",
type_to_string(ltmp, struct sha256_double, &b->blkid)); type_to_string(ltmp, struct bitcoin_blkid, &b->blkid));
assert(!block_map_get(&topo->block_map, &b->blkid)); assert(!block_map_get(&topo->block_map, &b->blkid));
b->next = next; b->next = next;
b->topo = topo; b->topo = topo;
@@ -443,7 +443,7 @@ static void rawblock_tip(struct bitcoind *bitcoind,
} }
static void check_chaintip(struct bitcoind *bitcoind, static void check_chaintip(struct bitcoind *bitcoind,
const struct sha256_double *tipid, const struct bitcoin_blkid *tipid,
struct chain_topology *topo) struct chain_topology *topo)
{ {
/* 0 is the main tip. */ /* 0 is the main tip. */
@@ -478,7 +478,7 @@ static void init_topo(struct bitcoind *bitcoind,
} }
static void get_init_block(struct bitcoind *bitcoind, static void get_init_block(struct bitcoind *bitcoind,
const struct sha256_double *blkid, const struct bitcoin_blkid *blkid,
struct chain_topology *topo) struct chain_topology *topo)
{ {
bitcoind_getrawblock(bitcoind, blkid, init_topo, topo); bitcoind_getrawblock(bitcoind, blkid, init_topo, topo);

View File

@@ -16,7 +16,6 @@ struct bitcoind;
struct command; struct command;
struct lightningd; struct lightningd;
struct peer; struct peer;
struct sha256_double;
struct txwatch; struct txwatch;
enum feerate { enum feerate {
@@ -50,7 +49,7 @@ struct block {
struct block *next; struct block *next;
/* Key for hash table */ /* Key for hash table */
struct sha256_double blkid; struct bitcoin_blkid blkid;
/* Transactions in this block we care about */ /* Transactions in this block we care about */
const struct bitcoin_tx **txs; const struct bitcoin_tx **txs;
@@ -66,12 +65,12 @@ struct block {
}; };
/* Hash blocks by sha */ /* Hash blocks by sha */
static inline const struct sha256_double *keyof_block_map(const struct block *b) static inline const struct bitcoin_blkid *keyof_block_map(const struct block *b)
{ {
return &b->blkid; return &b->blkid;
} }
static inline size_t hash_sha(const struct sha256_double *key) static inline size_t hash_sha(const struct bitcoin_blkid *key)
{ {
size_t ret; size_t ret;
@@ -79,7 +78,7 @@ static inline size_t hash_sha(const struct sha256_double *key)
return ret; return ret;
} }
static inline bool block_eq(const struct block *b, const struct sha256_double *key) static inline bool block_eq(const struct block *b, const struct bitcoin_blkid *key)
{ {
return structeq(&b->blkid, key); return structeq(&b->blkid, key);
} }

View File

@@ -461,12 +461,12 @@ static bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
u16 ignored_u16; u16 ignored_u16;
u8 ignored_u8; u8 ignored_u8;
struct pubkey ignored_pubkey; struct pubkey ignored_pubkey;
struct sha256_double ignored_shadouble; struct bitcoin_blkid ignored_chainhash;
if (fromwire_channel_reestablish(in_pkt, NULL, channel_id, if (fromwire_channel_reestablish(in_pkt, NULL, channel_id,
&ignored_u64, &ignored_u64)) &ignored_u64, &ignored_u64))
return true; return true;
if (fromwire_open_channel(in_pkt, NULL, &ignored_shadouble, if (fromwire_open_channel(in_pkt, NULL, &ignored_chainhash,
channel_id, &ignored_u64, channel_id, &ignored_u64,
&ignored_u64, &ignored_u64, &ignored_u64, &ignored_u64,
&ignored_u64, &ignored_u64, &ignored_u64, &ignored_u64,

View File

@@ -529,7 +529,7 @@ static u8 *fundee_channel(struct state *state,
struct pubkey their_funding_pubkey; struct pubkey their_funding_pubkey;
secp256k1_ecdsa_signature theirsig, sig; secp256k1_ecdsa_signature theirsig, sig;
struct bitcoin_tx *their_commit, *our_commit; struct bitcoin_tx *their_commit, *our_commit;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
u8 *msg; u8 *msg;
const u8 *wscript; const u8 *wscript;
u8 channel_flags; u8 channel_flags;
@@ -574,7 +574,7 @@ static u8 *fundee_channel(struct state *state,
negotiation_failed(state, true, negotiation_failed(state, true,
"Unknown chain-hash %s", "Unknown chain-hash %s",
type_to_string(peer_msg, type_to_string(peer_msg,
struct sha256_double, struct bitcoin_blkid,
&chain_hash)); &chain_hash));
} }

View File

@@ -18,7 +18,7 @@ type2size = {
'struct preimage': 32, 'struct preimage': 32,
'struct pubkey': 33, 'struct pubkey': 33,
'struct sha256': 32, 'struct sha256': 32,
'struct sha256_double': 32, 'struct bitcoin_blkid': 32,
'struct bitcoin_txid': 32, 'struct bitcoin_txid': 32,
'u64': 8, 'u64': 8,
'u32': 4, 'u32': 4,
@@ -78,7 +78,7 @@ partialtypemap = {
'signature': FieldType('secp256k1_ecdsa_signature'), 'signature': FieldType('secp256k1_ecdsa_signature'),
'features': FieldType('u8'), 'features': FieldType('u8'),
'channel_id': FieldType('struct channel_id'), 'channel_id': FieldType('struct channel_id'),
'chain_hash': FieldType('struct sha256_double'), 'chain_hash': FieldType('struct bitcoin_blkid'),
'funding_txid': FieldType('struct bitcoin_txid'), 'funding_txid': FieldType('struct bitcoin_txid'),
'pad': FieldType('pad'), 'pad': FieldType('pad'),
} }

View File

@@ -183,6 +183,12 @@ void fromwire_bitcoin_txid(const u8 **cursor, size_t *max,
fromwire_sha256_double(cursor, max, &txid->shad); fromwire_sha256_double(cursor, max, &txid->shad);
} }
void fromwire_bitcoin_blkid(const u8 **cursor, size_t *max,
struct bitcoin_blkid *blkid)
{
fromwire_sha256_double(cursor, max, &blkid->shad);
}
void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage) void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage)
{ {
fromwire(cursor, max, preimage, sizeof(*preimage)); fromwire(cursor, max, preimage, sizeof(*preimage));

View File

@@ -128,7 +128,7 @@ struct msg_channel_update {
u64 htlc_minimum_msat; u64 htlc_minimum_msat;
u32 fee_base_msat; u32 fee_base_msat;
u32 fee_proportional_millionths; u32 fee_proportional_millionths;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
struct short_channel_id short_channel_id; struct short_channel_id short_channel_id;
}; };
struct msg_funding_locked { struct msg_funding_locked {
@@ -156,7 +156,7 @@ struct msg_node_announcement {
u8 *addresses; u8 *addresses;
}; };
struct msg_open_channel { struct msg_open_channel {
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
struct channel_id temporary_channel_id; struct channel_id temporary_channel_id;
u64 funding_satoshis; u64 funding_satoshis;
u64 push_msat; u64 push_msat;
@@ -186,7 +186,7 @@ struct msg_channel_announcement {
secp256k1_ecdsa_signature bitcoin_signature_1; secp256k1_ecdsa_signature bitcoin_signature_1;
secp256k1_ecdsa_signature bitcoin_signature_2; secp256k1_ecdsa_signature bitcoin_signature_2;
u8 *features; u8 *features;
struct sha256_double chain_hash; struct bitcoin_blkid chain_hash;
struct short_channel_id short_channel_id; struct short_channel_id short_channel_id;
struct pubkey node_id_1; struct pubkey node_id_1;
struct pubkey node_id_2; struct pubkey node_id_2;

View File

@@ -125,6 +125,11 @@ void towire_bitcoin_txid(u8 **pptr, const struct bitcoin_txid *txid)
towire_sha256_double(pptr, &txid->shad); towire_sha256_double(pptr, &txid->shad);
} }
void towire_bitcoin_blkid(u8 **pptr, const struct bitcoin_blkid *blkid)
{
towire_sha256_double(pptr, &blkid->shad);
}
void towire_preimage(u8 **pptr, const struct preimage *preimage) void towire_preimage(u8 **pptr, const struct preimage *preimage)
{ {
towire(pptr, preimage, sizeof(*preimage)); towire(pptr, preimage, sizeof(*preimage));

View File

@@ -1,6 +1,7 @@
#ifndef LIGHTNING_WIRE_WIRE_H #ifndef LIGHTNING_WIRE_WIRE_H
#define LIGHTNING_WIRE_WIRE_H #define LIGHTNING_WIRE_WIRE_H
#include "config.h" #include "config.h"
#include <bitcoin/block.h>
#include <bitcoin/privkey.h> #include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h> #include <bitcoin/pubkey.h>
#include <bitcoin/shadouble.h> #include <bitcoin/shadouble.h>
@@ -15,6 +16,7 @@ struct channel_id {
u8 id[32]; u8 id[32];
}; };
struct bitcoin_blkid;
struct bitcoin_txid; struct bitcoin_txid;
struct preimage; struct preimage;
struct ripemd160; struct ripemd160;
@@ -40,6 +42,7 @@ void towire_short_channel_id(u8 **pptr,
void towire_sha256(u8 **pptr, const struct sha256 *sha256); void towire_sha256(u8 **pptr, const struct sha256 *sha256);
void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d); void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d);
void towire_bitcoin_txid(u8 **pptr, const struct bitcoin_txid *txid); void towire_bitcoin_txid(u8 **pptr, const struct bitcoin_txid *txid);
void towire_bitcoin_blkid(u8 **pptr, const struct bitcoin_blkid *blkid);
void towire_preimage(u8 **pptr, const struct preimage *preimage); void towire_preimage(u8 **pptr, const struct preimage *preimage);
void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd); void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd);
void towire_u8(u8 **pptr, u8 v); void towire_u8(u8 **pptr, u8 v);
@@ -74,6 +77,8 @@ void fromwire_sha256_double(const u8 **cursor, size_t *max,
struct sha256_double *sha256d); struct sha256_double *sha256d);
void fromwire_bitcoin_txid(const u8 **cursor, size_t *max, void fromwire_bitcoin_txid(const u8 **cursor, size_t *max,
struct bitcoin_txid *txid); struct bitcoin_txid *txid);
void fromwire_bitcoin_blkid(const u8 **cursor, size_t *max,
struct bitcoin_blkid *blkid);
void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage); void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage);
void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd); void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd);
void fromwire_pad(const u8 **cursor, size_t *max, size_t num); void fromwire_pad(const u8 **cursor, size_t *max, size_t num);