generate-wire.py: add --bolt arg, use size->type hacks only when that's specified.

For our own internal comms CSVs, we should always name explicit types.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-09-28 13:11:19 +09:30
committed by Christian Decker
parent 1b31d1c5a0
commit 32631b4278
8 changed files with 118 additions and 119 deletions

View File

@@ -8,27 +8,27 @@ channel_normal_operation,11001
channel_init,1000 channel_init,1000
channel_init,,chain_hash,struct sha256_double channel_init,,chain_hash,struct sha256_double
channel_init,,funding_txid,struct sha256_double channel_init,,funding_txid,struct sha256_double
channel_init,,funding_txout,2 channel_init,,funding_txout,u16
channel_init,,funding_satoshi,8 channel_init,,funding_satoshi,u64
channel_init,,our_config,struct channel_config channel_init,,our_config,struct channel_config
channel_init,,their_config,struct channel_config channel_init,,their_config,struct channel_config
channel_init,,feerate_per_kw,4 channel_init,,feerate_per_kw,u32
channel_init,,first_commit_sig,secp256k1_ecdsa_signature channel_init,,first_commit_sig,secp256k1_ecdsa_signature
channel_init,,crypto_state,struct crypto_state channel_init,,crypto_state,struct crypto_state
channel_init,,remote_fundingkey,33 channel_init,,remote_fundingkey,struct pubkey
channel_init,,revocation_basepoint,33 channel_init,,revocation_basepoint,struct pubkey
channel_init,,payment_basepoint,33 channel_init,,payment_basepoint,struct pubkey
channel_init,,delayed_payment_basepoint,33 channel_init,,delayed_payment_basepoint,struct pubkey
channel_init,,remote_per_commit,33 channel_init,,remote_per_commit,struct pubkey
channel_init,,old_remote_per_commit,33 channel_init,,old_remote_per_commit,struct pubkey
channel_init,,funder,enum side channel_init,,funder,enum side
channel_init,,fee_base,4 channel_init,,fee_base,u32
channel_init,,fee_proportional,4 channel_init,,fee_proportional,u32
channel_init,,local_msatoshi,8 channel_init,,local_msatoshi,u64
channel_init,,seed,struct privkey channel_init,,seed,struct privkey
channel_init,,local_node_id,struct pubkey channel_init,,local_node_id,struct pubkey
channel_init,,remote_node_id,struct pubkey channel_init,,remote_node_id,struct pubkey
channel_init,,commit_msec,4 channel_init,,commit_msec,u32
channel_init,,cltv_delta,u16 channel_init,,cltv_delta,u16
channel_init,,last_was_revoke,bool channel_init,,last_was_revoke,bool
channel_init,,num_last_sent_commit,u16 channel_init,,num_last_sent_commit,u16
@@ -66,32 +66,32 @@ channel_funding_announce_depth,1003
# Tell channel to offer this htlc # Tell channel to offer this htlc
channel_offer_htlc,1004 channel_offer_htlc,1004
channel_offer_htlc,,amount_msat,8 channel_offer_htlc,,amount_msat,u64
channel_offer_htlc,,cltv_expiry,4 channel_offer_htlc,,cltv_expiry,u32
channel_offer_htlc,,payment_hash,32 channel_offer_htlc,,payment_hash,struct sha256
channel_offer_htlc,,onion_routing_packet,1366*u8 channel_offer_htlc,,onion_routing_packet,1366*u8
# Reply; synchronous since IDs have to increment. # Reply; synchronous since IDs have to increment.
channel_offer_htlc_reply,1104 channel_offer_htlc_reply,1104
channel_offer_htlc_reply,,id,8 channel_offer_htlc_reply,,id,u64
# Zero failure code means success. # Zero failure code means success.
channel_offer_htlc_reply,,failure_code,2 channel_offer_htlc_reply,,failure_code,u16
channel_offer_htlc_reply,,failurestrlen,2 channel_offer_htlc_reply,,failurestrlen,u16
channel_offer_htlc_reply,,failurestr,failurestrlen*u8 channel_offer_htlc_reply,,failurestr,failurestrlen*u8
# Main daemon found out the preimage for an htlc # Main daemon found out the preimage for an htlc
#include <bitcoin/preimage.h> #include <bitcoin/preimage.h>
channel_fulfill_htlc,1005 channel_fulfill_htlc,1005
channel_fulfill_htlc,,id,8 channel_fulfill_htlc,,id,u64
channel_fulfill_htlc,,payment_preimage,struct preimage channel_fulfill_htlc,,payment_preimage,struct preimage
# Main daemon says HTLC failed # Main daemon says HTLC failed
channel_fail_htlc,1006 channel_fail_htlc,1006
channel_fail_htlc,,id,8 channel_fail_htlc,,id,u64
# If malformed is non-zero, it's a BADONION code # If malformed is non-zero, it's a BADONION code
channel_fail_htlc,,malformed,u16 channel_fail_htlc,,malformed,u16
# Otherwise, error_pkt contains failreason. # Otherwise, error_pkt contains failreason.
channel_fail_htlc,,len,2 channel_fail_htlc,,len,u16
channel_fail_htlc,,error_pkt,len*u8 channel_fail_htlc,,error_pkt,len*u8
# Ping/pong test. # Ping/pong test.
1 # Received and sent funding_locked
8 channel_init,,funding_txid,struct sha256_double
9 channel_init,,funding_txout,2 channel_init,,funding_txout,u16
10 channel_init,,funding_satoshi,8 channel_init,,funding_satoshi,u64
11 channel_init,,our_config,struct channel_config
12 channel_init,,their_config,struct channel_config
13 channel_init,,feerate_per_kw,4 channel_init,,feerate_per_kw,u32
14 channel_init,,first_commit_sig,secp256k1_ecdsa_signature
15 channel_init,,crypto_state,struct crypto_state
16 channel_init,,remote_fundingkey,33 channel_init,,remote_fundingkey,struct pubkey
17 channel_init,,revocation_basepoint,33 channel_init,,revocation_basepoint,struct pubkey
18 channel_init,,payment_basepoint,33 channel_init,,payment_basepoint,struct pubkey
19 channel_init,,delayed_payment_basepoint,33 channel_init,,delayed_payment_basepoint,struct pubkey
20 channel_init,,remote_per_commit,33 channel_init,,remote_per_commit,struct pubkey
21 channel_init,,old_remote_per_commit,33 channel_init,,old_remote_per_commit,struct pubkey
22 channel_init,,funder,enum side
23 channel_init,,fee_base,4 channel_init,,fee_base,u32
24 channel_init,,fee_proportional,4 channel_init,,fee_proportional,u32
25 channel_init,,local_msatoshi,8 channel_init,,local_msatoshi,u64
26 channel_init,,seed,struct privkey
27 channel_init,,local_node_id,struct pubkey
28 channel_init,,remote_node_id,struct pubkey
29 channel_init,,commit_msec,4 channel_init,,commit_msec,u32
30 channel_init,,cltv_delta,u16
31 channel_init,,last_was_revoke,bool
32 channel_init,,num_last_sent_commit,u16
33 channel_init,,last_sent_commit,num_last_sent_commit*struct changed_htlc
34 channel_init,,next_index_local,u64
66 channel_offer_htlc,,payment_hash,32 channel_offer_htlc,,payment_hash,struct sha256
67 channel_offer_htlc,,onion_routing_packet,1366*u8
68 # Reply; synchronous since IDs have to increment.
69 channel_offer_htlc_reply,1104
70 channel_offer_htlc_reply,,id,8 channel_offer_htlc_reply,,id,u64
71 # Zero failure code means success.
72 channel_offer_htlc_reply,,failure_code,2 channel_offer_htlc_reply,,failure_code,u16
73 channel_offer_htlc_reply,,failurestrlen,2 channel_offer_htlc_reply,,failurestrlen,u16
74 channel_offer_htlc_reply,,failurestr,failurestrlen*u8
75 # Main daemon found out the preimage for an htlc
76 #include <bitcoin/preimage.h>
77 channel_fulfill_htlc,1005
78 channel_fulfill_htlc,,id,8 channel_fulfill_htlc,,id,u64
79 channel_fulfill_htlc,,payment_preimage,struct preimage
80 # Main daemon says HTLC failed
81 channel_fail_htlc,1006
82 channel_fail_htlc,,id,8 channel_fail_htlc,,id,u64
83 # If malformed is non-zero, it's a BADONION code
84 channel_fail_htlc,,malformed,u16
85 # Otherwise, error_pkt contains failreason.
86 channel_fail_htlc,,len,2 channel_fail_htlc,,len,u16
87 channel_fail_htlc,,error_pkt,len*u8
88 # Ping/pong test.
89 channel_ping,1011
90 channel_ping,,num_pong_bytes,u16
91 channel_ping,,len,u16
92 channel_ping_reply,1111
93 channel_ping_reply,,totlen,u16
94 # Channeld tells the master that the channel has been announced
95 channel_announced,1012
96 # When we receive funding_locked.
97 channel_got_funding_locked,1019

View File

@@ -1,31 +1,31 @@
# Peers can give a bad message, we close their fd, but no harm done. # Peers can give a bad message, we close their fd, but no harm done.
gossipstatus_peer_bad_msg,13000 gossipstatus_peer_bad_msg,13000
gossipstatus_peer_bad_msg,,unique_id,8 gossipstatus_peer_bad_msg,,unique_id,u64
gossipstatus_peer_bad_msg,,len,2 gossipstatus_peer_bad_msg,,len,u16
gossipstatus_peer_bad_msg,,err,len*u8 gossipstatus_peer_bad_msg,,err,len*u8
# Misc problems like opening control fd. # Misc problems like opening control fd.
gossipstatus_peer_failed,13001 gossipstatus_peer_failed,13001
gossipstatus_peer_failed,,unique_id,8 gossipstatus_peer_failed,,unique_id,u64
gossipstatus_peer_failed,,len,2 gossipstatus_peer_failed,,len,u16
gossipstatus_peer_failed,,err,len*u8 gossipstatus_peer_failed,,err,len*u8
#include <common/cryptomsg.h> #include <common/cryptomsg.h>
# Initialize the gossip daemon # Initialize the gossip daemon
gossipctl_init,3000 gossipctl_init,3000
gossipctl_init,,broadcast_interval,4 gossipctl_init,,broadcast_interval,u32
gossipctl_init,,chain_hash,struct sha256_double gossipctl_init,,chain_hash,struct sha256_double
# These take an fd, but have no response # These take an fd, but have no response
# (if it is to move onto a channel, we get a status msg). # (if it is to move onto a channel, we get a status msg).
gossipctl_new_peer,3001 gossipctl_new_peer,3001
gossipctl_new_peer,,unique_id,8 gossipctl_new_peer,,unique_id,u64
gossipctl_new_peer,,crypto_state,struct crypto_state gossipctl_new_peer,,crypto_state,struct crypto_state
# Tell it to release a peer which has initialized. # Tell it to release a peer which has initialized.
gossipctl_release_peer,3002 gossipctl_release_peer,3002
gossipctl_release_peer,,unique_id,8 gossipctl_release_peer,,unique_id,u64
# This releases the peer and returns the cryptostate (followed two fds: peer and gossip) # This releases the peer and returns the cryptostate (followed two fds: peer and gossip)
gossipctl_release_peer_reply,3102 gossipctl_release_peer_reply,3102
@@ -36,17 +36,17 @@ gossipctl_release_peer_replyfail,3202
# This is where we save a peer's features. # This is where we save a peer's features.
#gossipstatus_peer_features,3001 #gossipstatus_peer_features,3001
#gossipstatus_peer_features,,unique_id,8 #gossipstatus_peer_features,,unique_id,u64
#gossipstatus_peer_features,,gflen,2 #gossipstatus_peer_features,,gflen,u16
#gossipstatus_peer_features,,globalfeatures,gflen #gossipstatus_peer_features,,globalfeatures,gflen*u8
#gossipstatus_peer_features,,lflen,2 #gossipstatus_peer_features,,lflen,u16
#gossipstatus_peer_features,,localfeatures,lflen #gossipstatus_peer_features,,localfeatures,lflen*u8
# Peer can send non-gossip packet (usually an open_channel) (followed two fds: peer and gossip) # Peer can send non-gossip packet (usually an open_channel) (followed two fds: peer and gossip)
gossipstatus_peer_nongossip,3004 gossipstatus_peer_nongossip,3004
gossipstatus_peer_nongossip,,unique_id,8 gossipstatus_peer_nongossip,,unique_id,u64
gossipstatus_peer_nongossip,,crypto_state,struct crypto_state gossipstatus_peer_nongossip,,crypto_state,struct crypto_state
gossipstatus_peer_nongossip,,len,2 gossipstatus_peer_nongossip,,len,u16
gossipstatus_peer_nongossip,,msg,len*u8 gossipstatus_peer_nongossip,,msg,len*u8
# Pass JSON-RPC getnodes call through # Pass JSON-RPC getnodes call through
@@ -94,12 +94,12 @@ gossip_resolve_channel_reply,,keys,num_keys*struct pubkey
# The main daemon forward some gossip message to gossipd, allows injecting # The main daemon forward some gossip message to gossipd, allows injecting
# arbitrary gossip messages. # arbitrary gossip messages.
gossip_forwarded_msg,3010 gossip_forwarded_msg,3010
gossip_forwarded_msg,,msglen,2 gossip_forwarded_msg,,msglen,u16
gossip_forwarded_msg,,msg,msglen gossip_forwarded_msg,,msg,msglen*u8
# If peer is still connected, fail it (master does this for reconnect) # If peer is still connected, fail it (master does this for reconnect)
gossipctl_fail_peer,3011 gossipctl_fail_peer,3011
gossipctl_fail_peer,,unique_id,8 gossipctl_fail_peer,,unique_id,u64
# Get a gossip fd for this peer (it has reconnected) # Get a gossip fd for this peer (it has reconnected)
gossipctl_get_peer_gossipfd,3012 gossipctl_get_peer_gossipfd,3012
1 # Peers can give a bad message, we close their fd, but no harm done.
2 gossipstatus_peer_bad_msg,13000
3 gossipstatus_peer_bad_msg,,unique_id,8 gossipstatus_peer_bad_msg,,unique_id,u64
4 gossipstatus_peer_bad_msg,,len,2 gossipstatus_peer_bad_msg,,len,u16
5 gossipstatus_peer_bad_msg,,err,len*u8
6 # Misc problems like opening control fd.
7 gossipstatus_peer_failed,13001
8 gossipstatus_peer_failed,,unique_id,8 gossipstatus_peer_failed,,unique_id,u64
9 gossipstatus_peer_failed,,len,2 gossipstatus_peer_failed,,len,u16
10 gossipstatus_peer_failed,,err,len*u8
11 #include <common/cryptomsg.h>
12 # Initialize the gossip daemon
13 gossipctl_init,3000
14 gossipctl_init,,broadcast_interval,4 gossipctl_init,,broadcast_interval,u32
15 gossipctl_init,,chain_hash,struct sha256_double
16 # These take an fd, but have no response
17 # (if it is to move onto a channel, we get a status msg).
18 gossipctl_new_peer,3001
19 gossipctl_new_peer,,unique_id,8 gossipctl_new_peer,,unique_id,u64
20 gossipctl_new_peer,,crypto_state,struct crypto_state
21 # Tell it to release a peer which has initialized.
22 gossipctl_release_peer,3002
23 gossipctl_release_peer,,unique_id,8 gossipctl_release_peer,,unique_id,u64
24 # This releases the peer and returns the cryptostate (followed two fds: peer and gossip)
25 gossipctl_release_peer_reply,3102
26 gossipctl_release_peer_reply,,crypto_state,struct crypto_state
27 # This is if we couldn't find the peer.
28 gossipctl_release_peer_replyfail,3202
29 # This is where we save a peer's features.
30 #gossipstatus_peer_features,3001
31 #gossipstatus_peer_features,,unique_id,8 #gossipstatus_peer_features,,unique_id,u64
36 # Peer can send non-gossip packet (usually an open_channel) (followed two fds: peer and gossip)
37 gossipstatus_peer_nongossip,3004
38 gossipstatus_peer_nongossip,,unique_id,8 gossipstatus_peer_nongossip,,unique_id,u64
39 gossipstatus_peer_nongossip,,crypto_state,struct crypto_state
40 gossipstatus_peer_nongossip,,len,2 gossipstatus_peer_nongossip,,len,u16
41 gossipstatus_peer_nongossip,,msg,len*u8
42 # Pass JSON-RPC getnodes call through
43 gossip_getnodes_request,3005
44 #include <lightningd/gossip_msg.h>
45 gossip_getnodes_reply,3105
46 gossip_getnodes_reply,,num_nodes,u16
47 gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry
48 # Pass JSON-RPC getroute call through
49 gossip_getroute_request,3006
50 gossip_getroute_request,,source,struct pubkey
51 gossip_getroute_request,,destination,struct pubkey
52 gossip_getroute_request,,msatoshi,u32
94
95
96
97
98
99
100
101
102
103
104
105

View File

@@ -10,22 +10,22 @@ respr_act_three,14013
success,4000 success,4000
handshake_responder,4001 handshake_responder,4001
handshake_responder,,my_id,33 handshake_responder,,my_id,struct pubkey
handshake_responder_reply,4101 handshake_responder_reply,4101
handshake_responder_reply,,initiator_id,33 handshake_responder_reply,,initiator_id,struct pubkey
handshake_responder_reply,,cs,struct crypto_state handshake_responder_reply,,cs,struct crypto_state
handshake_responder_reply,,gflen,2 handshake_responder_reply,,gflen,u16
handshake_responder_reply,,globalfeatures,gflen handshake_responder_reply,,globalfeatures,gflen*u8
handshake_responder_reply,,lflen,2 handshake_responder_reply,,lflen,u16
handshake_responder_reply,,localfeatures,lflen handshake_responder_reply,,localfeatures,lflen*u8
handshake_initiator,4002 handshake_initiator,4002
handshake_initiator,,my_id,33 handshake_initiator,,my_id,struct pubkey
handshake_initiator,,responder_id,33 handshake_initiator,,responder_id,struct pubkey
handshake_initiator_reply,4102 handshake_initiator_reply,4102
handshake_initiator_reply,,cs,struct crypto_state handshake_initiator_reply,,cs,struct crypto_state
handshake_initiator_reply,,gflen,2 handshake_initiator_reply,,gflen,u16
handshake_initiator_reply,,globalfeatures,gflen handshake_initiator_reply,,globalfeatures,gflen*u8
handshake_initiator_reply,,lflen,2 handshake_initiator_reply,,lflen,u16
handshake_initiator_reply,,localfeatures,lflen handshake_initiator_reply,,localfeatures,lflen*u8
1 #include <common/cryptomsg.h>
10 handshake_responder,4001
11 handshake_responder,,my_id,33 handshake_responder,,my_id,struct pubkey
12 handshake_responder_reply,4101
13 handshake_responder_reply,,initiator_id,33 handshake_responder_reply,,initiator_id,struct pubkey
14 handshake_responder_reply,,cs,struct crypto_state
15 handshake_responder_reply,,gflen,2 handshake_responder_reply,,gflen,u16
16 handshake_responder_reply,,globalfeatures,gflen handshake_responder_reply,,globalfeatures,gflen*u8
17 handshake_responder_reply,,lflen,2 handshake_responder_reply,,lflen,u16
18 handshake_responder_reply,,localfeatures,lflen handshake_responder_reply,,localfeatures,lflen*u8
19 handshake_initiator,4002
20 handshake_initiator,,my_id,33 handshake_initiator,,my_id,struct pubkey
21 handshake_initiator,,responder_id,33 handshake_initiator,,responder_id,struct pubkey
22 handshake_initiator_reply,4102
23 handshake_initiator_reply,,cs,struct crypto_state
24 handshake_initiator_reply,,gflen,2 handshake_initiator_reply,,gflen,u16
25 handshake_initiator_reply,,globalfeatures,gflen handshake_initiator_reply,,globalfeatures,gflen*u8
26 handshake_initiator_reply,,lflen,2 handshake_initiator_reply,,lflen,u16
27 handshake_initiator_reply,,localfeatures,lflen handshake_initiator_reply,,localfeatures,lflen*u8
28
29
30
31

View File

@@ -7,15 +7,15 @@ hsm_ecdh_resp,,ss,struct secret
hsm_cannouncement_sig_req,2 hsm_cannouncement_sig_req,2
hsm_cannouncement_sig_req,,bitcoin_id,struct pubkey hsm_cannouncement_sig_req,,bitcoin_id,struct pubkey
hsm_cannouncement_sig_req,,calen,u16 hsm_cannouncement_sig_req,,calen,u16
hsm_cannouncement_sig_req,,ca,calen hsm_cannouncement_sig_req,,ca,calen*u8
hsm_cannouncement_sig_reply,102 hsm_cannouncement_sig_reply,102
hsm_cannouncement_sig_reply,,node_signature,64 hsm_cannouncement_sig_reply,,node_signature,secp256k1_ecdsa_signature
hsm_cupdate_sig_req,3 hsm_cupdate_sig_req,3
hsm_cupdate_sig_req,,culen,u16 hsm_cupdate_sig_req,,culen,u16
hsm_cupdate_sig_req,,cu,culen hsm_cupdate_sig_req,,cu,culen*u8
hsm_cupdate_sig_reply,103 hsm_cupdate_sig_reply,103
hsm_cupdate_sig_reply,,culen,u16 hsm_cupdate_sig_reply,,culen,u16
hsm_cupdate_sig_reply,,cu,culen hsm_cupdate_sig_reply,,cu,culen*u8

View File

@@ -1,7 +1,7 @@
# Clients should not give a bad request but not the HSM's decision to crash. # Clients should not give a bad request but not the HSM's decision to crash.
hsmstatus_client_bad_request,1000 hsmstatus_client_bad_request,1000
hsmstatus_client_bad_request,,unique_id,8 hsmstatus_client_bad_request,,unique_id,u64
hsmstatus_client_bad_request,,len,2 hsmstatus_client_bad_request,,len,u16
hsmstatus_client_bad_request,,msg,len*u8 hsmstatus_client_bad_request,,msg,len*u8
# Start the HSM. # Start the HSM.
@@ -10,13 +10,13 @@ hsmctl_init,,new,bool
#include <common/bip32.h> #include <common/bip32.h>
hsmctl_init_reply,101 hsmctl_init_reply,101
hsmctl_init_reply,,node_id,33 hsmctl_init_reply,,node_id,struct pubkey
hsmctl_init_reply,,peer_seed,struct secret hsmctl_init_reply,,peer_seed,struct secret
hsmctl_init_reply,,bip32,struct ext_key hsmctl_init_reply,,bip32,struct ext_key
# ECDH returns an fd. # ECDH returns an fd.
hsmctl_hsmfd_ecdh,3 hsmctl_hsmfd_ecdh,3
hsmctl_hsmfd_ecdh,,unique_id,8 hsmctl_hsmfd_ecdh,,unique_id,u64
# No contents, just an fd. # No contents, just an fd.
hsmctl_hsmfd_ecdh_fd_reply,103 hsmctl_hsmfd_ecdh_fd_reply,103
@@ -25,28 +25,28 @@ hsmctl_hsmfd_ecdh_fd_reply,103
#include <common/utxo.h> #include <common/utxo.h>
# FIXME: This should also take their commit sig & details, to verify. # FIXME: This should also take their commit sig & details, to verify.
hsmctl_sign_funding,4 hsmctl_sign_funding,4
hsmctl_sign_funding,,satoshi_out,8 hsmctl_sign_funding,,satoshi_out,u64
hsmctl_sign_funding,,change_out,8 hsmctl_sign_funding,,change_out,u64
hsmctl_sign_funding,,change_keyindex,4 hsmctl_sign_funding,,change_keyindex,u32
hsmctl_sign_funding,,our_pubkey,33 hsmctl_sign_funding,,our_pubkey,struct pubkey
hsmctl_sign_funding,,their_pubkey,33 hsmctl_sign_funding,,their_pubkey,struct pubkey
hsmctl_sign_funding,,num_inputs,2 hsmctl_sign_funding,,num_inputs,u16
hsmctl_sign_funding,,inputs,num_inputs*struct utxo hsmctl_sign_funding,,inputs,num_inputs*struct utxo
hsmctl_sign_funding_reply,104 hsmctl_sign_funding_reply,104
hsmctl_sign_funding_reply,,num_sigs,2 hsmctl_sign_funding_reply,,num_sigs,u16
hsmctl_sign_funding_reply,,sig,num_sigs*secp256k1_ecdsa_signature hsmctl_sign_funding_reply,,sig,num_sigs*secp256k1_ecdsa_signature
# Request a client socket for a `channeld`, allows signing announcements # Request a client socket for a `channeld`, allows signing announcements
hsmctl_hsmfd_channeld,5 hsmctl_hsmfd_channeld,5
hsmctl_hsmfd_channeld,,unique_id,8 hsmctl_hsmfd_channeld,,unique_id,u64
# Empty reply, just an fd # Empty reply, just an fd
hsmctl_hsmfd_channeld_reply,105 hsmctl_hsmfd_channeld_reply,105
# Master asks the HSM to sign a node_announcement # Master asks the HSM to sign a node_announcement
hsmctl_node_announcement_sig_req,6 hsmctl_node_announcement_sig_req,6
hsmctl_node_announcement_sig_req,,annlen,2 hsmctl_node_announcement_sig_req,,annlen,u16
hsmctl_node_announcement_sig_req,,announcement,annlen*u8 hsmctl_node_announcement_sig_req,,announcement,annlen*u8
hsmctl_node_announcement_sig_reply,106 hsmctl_node_announcement_sig_reply,106
@@ -54,13 +54,13 @@ hsmctl_node_announcement_sig_reply,,signature,secp256k1_ecdsa_signature
# Sign a withdrawal request # Sign a withdrawal request
hsmctl_sign_withdrawal,7 hsmctl_sign_withdrawal,7
hsmctl_sign_withdrawal,,satoshi_out,8 hsmctl_sign_withdrawal,,satoshi_out,u64
hsmctl_sign_withdrawal,,change_out,8 hsmctl_sign_withdrawal,,change_out,u64
hsmctl_sign_withdrawal,,change_keyindex,4 hsmctl_sign_withdrawal,,change_keyindex,u32
hsmctl_sign_withdrawal,,pkh,20*u8 hsmctl_sign_withdrawal,,pkh,20*u8
hsmctl_sign_withdrawal,,num_inputs,2 hsmctl_sign_withdrawal,,num_inputs,u16
hsmctl_sign_withdrawal,,inputs,num_inputs*struct utxo hsmctl_sign_withdrawal,,inputs,num_inputs*struct utxo
hsmctl_sign_withdrawal_reply,107 hsmctl_sign_withdrawal_reply,107
hsmctl_sign_withdrawal_reply,,num_sigs,2 hsmctl_sign_withdrawal_reply,,num_sigs,u16
hsmctl_sign_withdrawal_reply,,sig,num_sigs*secp256k1_ecdsa_signature hsmctl_sign_withdrawal_reply,,sig,num_sigs*secp256k1_ecdsa_signature
1 # Clients should not give a bad request but not the HSM's decision to crash.
2 hsmstatus_client_bad_request,1000
3 hsmstatus_client_bad_request,,unique_id,8 hsmstatus_client_bad_request,,unique_id,u64
4 hsmstatus_client_bad_request,,len,2 hsmstatus_client_bad_request,,len,u16
5 hsmstatus_client_bad_request,,msg,len*u8
6 # Start the HSM.
7 hsmctl_init,1
10 hsmctl_init_reply,101
11 hsmctl_init_reply,,node_id,33 hsmctl_init_reply,,node_id,struct pubkey
12 hsmctl_init_reply,,peer_seed,struct secret
13 hsmctl_init_reply,,bip32,struct ext_key
14 # ECDH returns an fd.
15 hsmctl_hsmfd_ecdh,3
16 hsmctl_hsmfd_ecdh,,unique_id,8 hsmctl_hsmfd_ecdh,,unique_id,u64
17 # No contents, just an fd.
18 hsmctl_hsmfd_ecdh_fd_reply,103
19 # Return signature for a funding tx.
20 #include <common/utxo.h>
21 # FIXME: This should also take their commit sig & details, to verify.
22 hsmctl_sign_funding,4
25 hsmctl_sign_funding,,change_keyindex,4 hsmctl_sign_funding,,change_keyindex,u32
26 hsmctl_sign_funding,,our_pubkey,33 hsmctl_sign_funding,,our_pubkey,struct pubkey
27 hsmctl_sign_funding,,their_pubkey,33 hsmctl_sign_funding,,their_pubkey,struct pubkey
28 hsmctl_sign_funding,,num_inputs,2 hsmctl_sign_funding,,num_inputs,u16
29 hsmctl_sign_funding,,inputs,num_inputs*struct utxo
30 hsmctl_sign_funding_reply,104
31 hsmctl_sign_funding_reply,,num_sigs,2 hsmctl_sign_funding_reply,,num_sigs,u16
32 hsmctl_sign_funding_reply,,sig,num_sigs*secp256k1_ecdsa_signature
33 # Request a client socket for a `channeld`, allows signing announcements
34 hsmctl_hsmfd_channeld,5
35 hsmctl_hsmfd_channeld,,unique_id,8 hsmctl_hsmfd_channeld,,unique_id,u64
36 # Empty reply, just an fd
37 hsmctl_hsmfd_channeld_reply,105
38 # Master asks the HSM to sign a node_announcement
39 hsmctl_node_announcement_sig_req,6
40 hsmctl_node_announcement_sig_req,,annlen,2 hsmctl_node_announcement_sig_req,,annlen,u16
41 hsmctl_node_announcement_sig_req,,announcement,annlen*u8
42 hsmctl_node_announcement_sig_reply,106
43 hsmctl_node_announcement_sig_reply,,signature,secp256k1_ecdsa_signature
44 # Sign a withdrawal request
45 hsmctl_sign_withdrawal,7
46 hsmctl_sign_withdrawal,,satoshi_out,8 hsmctl_sign_withdrawal,,satoshi_out,u64
47 hsmctl_sign_withdrawal,,change_out,8 hsmctl_sign_withdrawal,,change_out,u64
48 hsmctl_sign_withdrawal,,change_keyindex,4 hsmctl_sign_withdrawal,,change_keyindex,u32
49 hsmctl_sign_withdrawal,,pkh,20*u8
50 hsmctl_sign_withdrawal,,num_inputs,2 hsmctl_sign_withdrawal,,num_inputs,u16
51 hsmctl_sign_withdrawal,,inputs,num_inputs*struct utxo
52 hsmctl_sign_withdrawal_reply,107
54 hsmctl_sign_withdrawal_reply,,sig,num_sigs*secp256k1_ecdsa_signature
55
56
57
58
59
60
61
62
63
64
65
66

View File

@@ -2,12 +2,12 @@
#include <common/channel_config.h> #include <common/channel_config.h>
opening_init,6000 opening_init,6000
# Which network are we configured for (as index into the chainparams)? # Which network are we configured for (as index into the chainparams)?
opening_init,,network_index,4 opening_init,,network_index,u32
# Base configuration we'll offer (channel reserve will vary with amount) # Base configuration we'll offer (channel reserve will vary with amount)
opening_init,,our_config,struct channel_config opening_init,,our_config,struct channel_config
# Minimum/maximum configuration values we'll accept # Minimum/maximum configuration values we'll accept
opening_init,,max_to_self_delay,4 opening_init,,max_to_self_delay,u32
opening_init,,min_effective_htlc_capacity_msat,8 opening_init,,min_effective_htlc_capacity_msat,u64
opening_init,,crypto_state,struct crypto_state opening_init,,crypto_state,struct crypto_state
# Seed to generate all the keys from # Seed to generate all the keys from
opening_init,,seed,struct privkey opening_init,,seed,struct privkey
@@ -16,10 +16,10 @@ opening_init,,seed,struct privkey
#include <common/htlc_wire.h> #include <common/htlc_wire.h>
# This means we offer the open. # This means we offer the open.
opening_funder,6001 opening_funder,6001
opening_funder,,funding_satoshis,8 opening_funder,,funding_satoshis,u64
opening_funder,,push_msat,8 opening_funder,,push_msat,u64
opening_funder,,feerate_per_kw,4 opening_funder,,feerate_per_kw,u32
opening_funder,,max_minimum_depth,4 opening_funder,,max_minimum_depth,u32
opening_funder,,change_satoshis,u64 opening_funder,,change_satoshis,u64
opening_funder,,change_keyindex,u32 opening_funder,,change_keyindex,u32
opening_funder,,channel_flags,u8 opening_funder,,channel_flags,u8
@@ -34,21 +34,21 @@ opening_funder_reply,,their_config,struct channel_config
opening_funder_reply,,first_commit,struct bitcoin_tx opening_funder_reply,,first_commit,struct bitcoin_tx
opening_funder_reply,,first_commit_sig,secp256k1_ecdsa_signature opening_funder_reply,,first_commit_sig,secp256k1_ecdsa_signature
opening_funder_reply,,crypto_state,struct crypto_state opening_funder_reply,,crypto_state,struct crypto_state
opening_funder_reply,,revocation_basepoint,33 opening_funder_reply,,revocation_basepoint,struct pubkey
opening_funder_reply,,payment_basepoint,33 opening_funder_reply,,payment_basepoint,struct pubkey
opening_funder_reply,,delayed_payment_basepoint,33 opening_funder_reply,,delayed_payment_basepoint,struct pubkey
opening_funder_reply,,their_per_commit_point,33 opening_funder_reply,,their_per_commit_point,struct pubkey
opening_funder_reply,,minimum_depth,4 opening_funder_reply,,minimum_depth,u32
opening_funder_reply,,remote_fundingkey,33 opening_funder_reply,,remote_fundingkey,struct pubkey
opening_funder_reply,,funding_txid,struct sha256_double opening_funder_reply,,funding_txid,struct sha256_double
opening_funder_reply,,feerate_per_kw,4 opening_funder_reply,,feerate_per_kw,u32
# This means they offer the open (contains their offer packet) # This means they offer the open (contains their offer packet)
opening_fundee,6003 opening_fundee,6003
opening_fundee,,minimum_depth,4 opening_fundee,,minimum_depth,u32
opening_fundee,,min_feerate,4 opening_fundee,,min_feerate,u32
opening_fundee,,max_feerate,4 opening_fundee,,max_feerate,u32
opening_fundee,,len,2 opening_fundee,,len,u16
opening_fundee,,msg,len*u8 opening_fundee,,msg,len*u8
# This gives their txid and info, means we can send funding_signed: we're done. # This gives their txid and info, means we can send funding_signed: we're done.
@@ -57,17 +57,17 @@ opening_fundee_reply,,their_config,struct channel_config
opening_fundee_reply,,first_commit,struct bitcoin_tx opening_fundee_reply,,first_commit,struct bitcoin_tx
opening_fundee_reply,,first_commit_sig,secp256k1_ecdsa_signature opening_fundee_reply,,first_commit_sig,secp256k1_ecdsa_signature
opening_fundee_reply,,crypto_state,struct crypto_state opening_fundee_reply,,crypto_state,struct crypto_state
opening_fundee_reply,,revocation_basepoint,33 opening_fundee_reply,,revocation_basepoint,struct pubkey
opening_fundee_reply,,payment_basepoint,33 opening_fundee_reply,,payment_basepoint,struct pubkey
opening_fundee_reply,,delayed_payment_basepoint,33 opening_fundee_reply,,delayed_payment_basepoint,struct pubkey
opening_fundee_reply,,their_per_commit_point,33 opening_fundee_reply,,their_per_commit_point,struct pubkey
opening_fundee_reply,,remote_fundingkey,33 opening_fundee_reply,,remote_fundingkey,struct pubkey
opening_fundee_reply,,funding_txid,struct sha256_double opening_fundee_reply,,funding_txid,struct sha256_double
opening_fundee_reply,,funding_txout,u16 opening_fundee_reply,,funding_txout,u16
opening_fundee_reply,,funding_satoshis,8 opening_fundee_reply,,funding_satoshis,u64
opening_fundee_reply,,push_msat,8 opening_fundee_reply,,push_msat,u64
opening_fundee_reply,,channel_flags,u8 opening_fundee_reply,,channel_flags,u8
opening_fundee_reply,,feerate_per_kw,4 opening_fundee_reply,,feerate_per_kw,u32
# The (encrypted) funding signed message: send this and we're committed. # The (encrypted) funding signed message: send this and we're committed.
opening_fundee_reply,,msglen,u16 opening_fundee_reply,,msglen,u16
opening_fundee_reply,,funding_signed_msg,msglen*u8 opening_fundee_reply,,funding_signed_msg,msglen*u8
1 #include <common/cryptomsg.h>
2 #include <common/channel_config.h>
3 opening_init,6000
4 # Which network are we configured for (as index into the chainparams)?
5 opening_init,,network_index,4 opening_init,,network_index,u32
6 # Base configuration we'll offer (channel reserve will vary with amount)
7 opening_init,,our_config,struct channel_config
8 # Minimum/maximum configuration values we'll accept
9 opening_init,,max_to_self_delay,4 opening_init,,max_to_self_delay,u32
10 opening_init,,min_effective_htlc_capacity_msat,8 opening_init,,min_effective_htlc_capacity_msat,u64
11 opening_init,,crypto_state,struct crypto_state
12 # Seed to generate all the keys from
13 opening_init,,seed,struct privkey
16 # This means we offer the open.
17 opening_funder,6001
18 opening_funder,,funding_satoshis,8 opening_funder,,funding_satoshis,u64
19 opening_funder,,push_msat,8 opening_funder,,push_msat,u64
20 opening_funder,,feerate_per_kw,4 opening_funder,,feerate_per_kw,u32
21 opening_funder,,max_minimum_depth,4 opening_funder,,max_minimum_depth,u32
22 opening_funder,,change_satoshis,u64
23 opening_funder,,change_keyindex,u32
24 opening_funder,,channel_flags,u8
25 #include <common/utxo.h>
34 opening_funder_reply,,crypto_state,struct crypto_state
35 opening_funder_reply,,revocation_basepoint,33 opening_funder_reply,,revocation_basepoint,struct pubkey
36 opening_funder_reply,,payment_basepoint,33 opening_funder_reply,,payment_basepoint,struct pubkey
37 opening_funder_reply,,delayed_payment_basepoint,33 opening_funder_reply,,delayed_payment_basepoint,struct pubkey
38 opening_funder_reply,,their_per_commit_point,33 opening_funder_reply,,their_per_commit_point,struct pubkey
39 opening_funder_reply,,minimum_depth,4 opening_funder_reply,,minimum_depth,u32
40 opening_funder_reply,,remote_fundingkey,33 opening_funder_reply,,remote_fundingkey,struct pubkey
41 opening_funder_reply,,funding_txid,struct sha256_double
42 opening_funder_reply,,feerate_per_kw,4 opening_funder_reply,,feerate_per_kw,u32
43 # This means they offer the open (contains their offer packet)
44 opening_fundee,6003
45 opening_fundee,,minimum_depth,4 opening_fundee,,minimum_depth,u32
46 opening_fundee,,min_feerate,4 opening_fundee,,min_feerate,u32
47 opening_fundee,,max_feerate,4 opening_fundee,,max_feerate,u32
48 opening_fundee,,len,2 opening_fundee,,len,u16
49 opening_fundee,,msg,len*u8
50 # This gives their txid and info, means we can send funding_signed: we're done.
51 opening_fundee_reply,6103
52 opening_fundee_reply,,their_config,struct channel_config
53 opening_fundee_reply,,first_commit,struct bitcoin_tx
54 opening_fundee_reply,,first_commit_sig,secp256k1_ecdsa_signature
57 opening_fundee_reply,,payment_basepoint,33 opening_fundee_reply,,payment_basepoint,struct pubkey
58 opening_fundee_reply,,delayed_payment_basepoint,33 opening_fundee_reply,,delayed_payment_basepoint,struct pubkey
59 opening_fundee_reply,,their_per_commit_point,33 opening_fundee_reply,,their_per_commit_point,struct pubkey
60 opening_fundee_reply,,remote_fundingkey,33 opening_fundee_reply,,remote_fundingkey,struct pubkey
61 opening_fundee_reply,,funding_txid,struct sha256_double
62 opening_fundee_reply,,funding_txout,u16
63 opening_fundee_reply,,funding_satoshis,8 opening_fundee_reply,,funding_satoshis,u64
64 opening_fundee_reply,,push_msat,8 opening_fundee_reply,,push_msat,u64
65 opening_fundee_reply,,channel_flags,u8
66 opening_fundee_reply,,feerate_per_kw,4 opening_fundee_reply,,feerate_per_kw,u32
67 # The (encrypted) funding signed message: send this and we're committed.
68 opening_fundee_reply,,msglen,u16
69 opening_fundee_reply,,funding_signed_msg,msglen*u8
70
71
72
73

View File

@@ -34,7 +34,6 @@ varlen_structs = [
class FieldType(object): class FieldType(object):
def __init__(self,name): def __init__(self,name):
self.name = name self.name = name
self.tsize = FieldType._typesize(name)
def is_assignable(self): def is_assignable(self):
return self.name in ['u8', 'u16', 'u32', 'u64', 'bool'] or self.name.startswith('enum ') return self.name in ['u8', 'u16', 'u32', 'u64', 'bool'] or self.name.startswith('enum ')
@@ -116,27 +115,26 @@ class Field(object):
else: else:
self.num_elems = int(number) self.num_elems = int(number)
size = size.split('*')[1] size = size.split('*')[1]
else: elif options.bolt and size == prevname:
if size == prevname: # Raw length field, implies u8.
# Raw length field, implies u8. self.lenvar = size
self.lenvar = size size = '1'
size = 'u8'
try: # Bolts use just a number: Guess type based on size.
# Just a number? Guess based on size. if options.bolt:
base_size = int(size) base_size = int(size)
self.fieldtype = Field._guess_type(message,self.name,base_size) self.fieldtype = Field._guess_type(message,self.name,base_size)
# There are some arrays which we have to guess, based on sizes. # There are some arrays which we have to guess, based on sizes.
if base_size % self.fieldtype.tsize != 0: tsize = FieldType._typesize(self.fieldtype.name)
if base_size % tsize != 0:
raise ValueError('Invalid size {} for {}.{} not a multiple of {}' raise ValueError('Invalid size {} for {}.{} not a multiple of {}'
.format(base_size, .format(base_size,
self.message, self.message,
self.name, self.name,
self.fieldtype.tsize)) tsize))
self.num_elems = int(base_size / self.fieldtype.tsize) self.num_elems = int(base_size / tsize)
else:
except ValueError: # Real typename.
# Not a number; must be a type.
self.fieldtype = FieldType(size) self.fieldtype = FieldType(size)
def basetype(self): def basetype(self):
@@ -227,8 +225,8 @@ class Message(object):
for f in self.fields: for f in self.fields:
if f.name == field.lenvar: if f.name == field.lenvar:
if f.fieldtype.name != 'u16': if f.fieldtype.name != 'u16':
raise ValueError('Field {} has non-u16 length variable {}' raise ValueError('Field {} has non-u16 length variable {} (type {})'
.format(field.name, field.lenvar)) .format(field.name, field.lenvar, f.fieldtype.name))
if f.is_array() or f.is_variable_size(): if f.is_array() or f.is_variable_size():
raise ValueError('Field {} has non-simple length variable {}' raise ValueError('Field {} has non-simple length variable {}'
@@ -391,6 +389,7 @@ class Message(object):
parser = argparse.ArgumentParser(description='Generate C from from CSV') parser = argparse.ArgumentParser(description='Generate C from from CSV')
parser.add_argument('--header', action='store_true', help="Create wire header") parser.add_argument('--header', action='store_true', help="Create wire header")
parser.add_argument('--bolt', action='store_true', help="Generate wire-format for BOLT")
parser.add_argument('headerfilename', help='The filename of the header') parser.add_argument('headerfilename', help='The filename of the header')
parser.add_argument('enumname', help='The name of the enum to produce') parser.add_argument('enumname', help='The name of the enum to produce')
parser.add_argument('files', nargs='*', help='Files to read in (or stdin)') parser.add_argument('files', nargs='*', help='Files to read in (or stdin)')

View File

@@ -34,16 +34,16 @@ wire/gen_onion_wire_csv: FORCE
@set -e; if [ -f $(BOLT_EXTRACT) ]; then for f in $(BOLTDIR)/04*.md $(BOLT_EXTRACT); do if [ $$f -nt $@ -o ! -f $@ ]; then echo '#include <wire/onion_defs.h>' > $@ && $(BOLT_EXTRACT) --message-fields --message-types --check-alignment $(BOLTDIR)/04*.md >> $@; break; fi; done; fi @set -e; if [ -f $(BOLT_EXTRACT) ]; then for f in $(BOLTDIR)/04*.md $(BOLT_EXTRACT); do if [ $$f -nt $@ -o ! -f $@ ]; then echo '#include <wire/onion_defs.h>' > $@ && $(BOLT_EXTRACT) --message-fields --message-types --check-alignment $(BOLTDIR)/04*.md >> $@; break; fi; done; fi
wire/gen_peer_wire.h: $(WIRE_GEN) wire/gen_peer_wire_csv wire/gen_peer_wire.h: $(WIRE_GEN) wire/gen_peer_wire_csv
$(WIRE_GEN) --header $@ wire_type < wire/gen_peer_wire_csv > $@ $(WIRE_GEN) --bolt --header $@ wire_type < wire/gen_peer_wire_csv > $@
wire/gen_peer_wire.c: $(WIRE_GEN) wire/gen_peer_wire_csv wire/gen_peer_wire.c: $(WIRE_GEN) wire/gen_peer_wire_csv
$(WIRE_GEN) ${@:.c=.h} wire_type < wire/gen_peer_wire_csv > $@ $(WIRE_GEN) --bolt ${@:.c=.h} wire_type < wire/gen_peer_wire_csv > $@
wire/gen_onion_wire.h: $(WIRE_GEN) wire/gen_onion_wire_csv wire/gen_onion_wire.h: $(WIRE_GEN) wire/gen_onion_wire_csv
$(WIRE_GEN) --header $@ onion_type < wire/gen_onion_wire_csv > $@ $(WIRE_GEN) --bolt --header $@ onion_type < wire/gen_onion_wire_csv > $@
wire/gen_onion_wire.c: $(WIRE_GEN) wire/gen_onion_wire_csv wire/gen_onion_wire.c: $(WIRE_GEN) wire/gen_onion_wire_csv
$(WIRE_GEN) ${@:.c=.h} onion_type < wire/gen_onion_wire_csv > $@ $(WIRE_GEN) --bolt ${@:.c=.h} onion_type < wire/gen_onion_wire_csv > $@
check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%) check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%)