Browse Source

tools/generate-wire: use amount_msat / amount_sat for peer protocol.

Basically we tell it that every field ending in '_msat' is a struct
amount_msat, and 'satoshis' is an amount_sat.  The exceptions are
channel_update's fee_base_msat which is a u32, and
final_incorrect_htlc_amount's incoming_htlc_amt which is also a
'struct amount_msat'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
confirmed-only
Rusty Russell 6 years ago
parent
commit
28f5da7b2f
  1. 14
      channeld/channeld.c
  2. 4
      closingd/closingd.c
  3. 2
      devtools/print_wire.c
  4. 2
      devtools/print_wire.h
  5. 10
      gossipd/gossipd.c
  6. 10
      gossipd/routing.c
  7. 4
      gossipd/test/run-bench-find_route.c
  8. 4
      gossipd/test/run-find_route-specific.c
  9. 4
      gossipd/test/run-find_route.c
  10. 11
      hsmd/hsmd.c
  11. 43
      openingd/openingd.c
  12. 8
      tools/generate-wire.py
  13. 10
      wire/peer_wire.c
  14. 30
      wire/test/run-peer-wire.c

14
channeld/channeld.c

@ -596,7 +596,7 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg)
enum channel_add_err add_err;
struct htlc *htlc;
if (!fromwire_update_add_htlc(msg, &channel_id, &id, &amount.millisatoshis,
if (!fromwire_update_add_htlc(msg, &channel_id, &id, &amount,
&payment_hash, &cltv_expiry,
onion_routing_packet))
peer_failed(&peer->cs,
@ -866,12 +866,12 @@ static u8 *make_failmsg(const tal_t *ctx,
goto done;
case WIRE_AMOUNT_BELOW_MINIMUM:
channel_update = foreign_channel_update(ctx, peer, scid);
msg = towire_amount_below_minimum(ctx, htlc->amount.millisatoshis,
msg = towire_amount_below_minimum(ctx, htlc->amount,
channel_update);
goto done;
case WIRE_FEE_INSUFFICIENT:
channel_update = foreign_channel_update(ctx, peer, scid);
msg = towire_fee_insufficient(ctx, htlc->amount.millisatoshis,
msg = towire_fee_insufficient(ctx, htlc->amount,
channel_update);
goto done;
case WIRE_INCORRECT_CLTV_EXPIRY:
@ -888,7 +888,7 @@ static u8 *make_failmsg(const tal_t *ctx,
goto done;
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
msg = towire_incorrect_or_unknown_payment_details(
ctx, htlc->amount.millisatoshis);
ctx, htlc->amount);
goto done;
case WIRE_FINAL_EXPIRY_TOO_SOON:
msg = towire_final_expiry_too_soon(ctx);
@ -897,7 +897,7 @@ static u8 *make_failmsg(const tal_t *ctx,
msg = towire_final_incorrect_cltv_expiry(ctx, cltv_expiry);
goto done;
case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:
msg = towire_final_incorrect_htlc_amount(ctx, htlc->amount.millisatoshis);
msg = towire_final_incorrect_htlc_amount(ctx, htlc->amount);
goto done;
case WIRE_INVALID_ONION_VERSION:
msg = towire_invalid_onion_version(ctx, sha256);
@ -1899,7 +1899,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
if (h->state == SENT_ADD_COMMIT) {
u8 *msg = towire_update_add_htlc(NULL, &peer->channel_id,
h->id, h->amount.millisatoshis,
h->id, h->amount,
&h->rhash,
abs_locktime_to_blocks(
&h->expiry),
@ -2449,7 +2449,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
case CHANNEL_ERR_ADD_OK:
/* Tell the peer. */
msg = towire_update_add_htlc(NULL, &peer->channel_id,
peer->htlc_id, amount.millisatoshis,
peer->htlc_id, amount,
&payment_hash, cltv_expiry,
onion_routing_packet);
sync_crypto_write(&peer->cs, PEER_FD, take(msg));

4
closingd/closingd.c

@ -224,7 +224,7 @@ static void send_offer(struct crypto_state *cs,
type_to_string(tmpctx, struct amount_sat, &fee_to_offer));
assert(our_sig.sighash_type == SIGHASH_ALL);
msg = towire_closing_signed(NULL, channel_id, fee_to_offer.satoshis, &our_sig.s);
msg = towire_closing_signed(NULL, channel_id, fee_to_offer, &our_sig.s);
sync_crypto_write(cs, PEER_FD, take(msg));
}
@ -288,7 +288,7 @@ receive_offer(struct crypto_state *cs,
their_sig.sighash_type = SIGHASH_ALL;
if (!fromwire_closing_signed(msg, &their_channel_id,
&received_fee.satoshis, &their_sig.s))
&received_fee, &their_sig.s))
peer_failed(cs, channel_id,
"Expected closing_signed: %s",
tal_hex(tmpctx, msg));

2
devtools/print_wire.c

@ -180,4 +180,6 @@ PRINTWIRE_STRUCT_TYPE_TO_STRING(pubkey);
PRINTWIRE_STRUCT_TYPE_TO_STRING(sha256);
PRINTWIRE_STRUCT_TYPE_TO_STRING(secret);
PRINTWIRE_STRUCT_TYPE_TO_STRING(short_channel_id);
PRINTWIRE_STRUCT_TYPE_TO_STRING(amount_sat);
PRINTWIRE_STRUCT_TYPE_TO_STRING(amount_msat);
PRINTWIRE_TYPE_TO_STRING(secp256k1_ecdsa_signature, secp256k1_ecdsa_signature);

2
devtools/print_wire.h

@ -14,6 +14,8 @@ void printwire_u8_array(const char *fieldname, const u8 **cursor, size_t *plen,
void printwire_bitcoin_blkid(const char *fieldname, const struct bitcoin_blkid *bitcoin_blkid);
void printwire_bitcoin_txid(const char *fieldname, const struct bitcoin_txid *bitcoin_txid);
void printwire_channel_id(const char *fieldname, const struct channel_id *channel_id);
void printwire_amount_sat(const char *fieldname, const struct amount_sat *sat);
void printwire_amount_msat(const char *fieldname, const struct amount_msat *msat);
void printwire_preimage(const char *fieldname, const struct preimage *preimage);
void printwire_pubkey(const char *fieldname, const struct pubkey *pubkey);
void printwire_secp256k1_ecdsa_signature(const char *fieldname, const secp256k1_ecdsa_signature *);

10
gossipd/gossipd.c

@ -1241,10 +1241,10 @@ static void update_local_channel(struct daemon *daemon,
timestamp,
message_flags, channel_flags,
cltv_expiry_delta,
htlc_minimum.millisatoshis,
htlc_minimum,
fee_base_msat,
fee_proportional_millionths,
htlc_maximum.millisatoshis);
htlc_maximum);
/* Note that we treat the hsmd as synchronous. This is simple (no
* callback hell)!, but may need to change to async if we ever want
@ -2539,7 +2539,7 @@ static u8 *channel_update_from_onion_error(const tal_t *ctx,
const u8 *onion_message)
{
u8 *channel_update = NULL;
u64 unused64;
struct amount_msat unused_msat;
u32 unused32;
/* Identify failcodes that have some channel_update.
@ -2550,10 +2550,10 @@ static u8 *channel_update_from_onion_error(const tal_t *ctx,
onion_message,
&channel_update) &&
!fromwire_amount_below_minimum(ctx,
onion_message, &unused64,
onion_message, &unused_msat,
&channel_update) &&
!fromwire_fee_insufficient(ctx,
onion_message, &unused64,
onion_message, &unused_msat,
&channel_update) &&
!fromwire_incorrect_cltv_expiry(ctx,
onion_message, &unused32,

10
gossipd/routing.c

@ -1097,7 +1097,7 @@ bool routing_add_channel_update(struct routing_state *rstate,
if (!fromwire_channel_update(update, &signature, &chain_hash,
&short_channel_id, &timestamp,
&message_flags, &channel_flags,
&expiry, &htlc_minimum.millisatoshis, &fee_base_msat,
&expiry, &htlc_minimum, &fee_base_msat,
&fee_proportional_millionths))
return false;
/* If it's flagged as containing the optional field, reparse for
@ -1107,9 +1107,9 @@ bool routing_add_channel_update(struct routing_state *rstate,
update, &signature, &chain_hash,
&short_channel_id, &timestamp,
&message_flags, &channel_flags,
&expiry, &htlc_minimum.millisatoshis, &fee_base_msat,
&expiry, &htlc_minimum, &fee_base_msat,
&fee_proportional_millionths,
&htlc_maximum.millisatoshis))
&htlc_maximum))
return false;
chan = get_channel(rstate, &short_channel_id);
if (!chan)
@ -1176,7 +1176,7 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update TAKES,
u32 timestamp;
u8 message_flags, channel_flags;
u16 expiry;
u64 htlc_minimum_msat;
struct amount_msat htlc_minimum;
u32 fee_base_msat;
u32 fee_proportional_millionths;
struct bitcoin_blkid chain_hash;
@ -1190,7 +1190,7 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update TAKES,
&chain_hash, &short_channel_id,
&timestamp, &message_flags,
&channel_flags, &expiry,
&htlc_minimum_msat, &fee_base_msat,
&htlc_minimum, &fee_base_msat,
&fee_proportional_millionths)) {
err = towire_errorfmt(rstate, NULL,
"Malformed channel_update %s",

4
gossipd/test/run-bench-find_route.c

@ -38,10 +38,10 @@ void broadcast_del(struct broadcast_state *bstate UNNEEDED, u64 index UNNEEDED,
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p 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(); }
/* Generated stub for fromwire_channel_update */
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_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, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_channel_update_option_channel_htlc_max */
bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, u64 *htlc_maximum_msat UNNEEDED)
bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update_option_channel_htlc_max called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)

4
gossipd/test/run-find_route-specific.c

@ -27,10 +27,10 @@ void broadcast_del(struct broadcast_state *bstate UNNEEDED, u64 index UNNEEDED,
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p 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(); }
/* Generated stub for fromwire_channel_update */
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_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, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_channel_update_option_channel_htlc_max */
bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, u64 *htlc_maximum_msat UNNEEDED)
bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update_option_channel_htlc_max called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)

4
gossipd/test/run-find_route.c

@ -25,10 +25,10 @@ void broadcast_del(struct broadcast_state *bstate UNNEEDED, u64 index UNNEEDED,
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p 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(); }
/* Generated stub for fromwire_channel_update */
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_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, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_channel_update_option_channel_htlc_max */
bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, u64 *htlc_maximum_msat UNNEEDED)
bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u8 *message_flags UNNEEDED, u8 *channel_flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update_option_channel_htlc_max called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)

11
hsmd/hsmd.c

@ -654,8 +654,7 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
secp256k1_ecdsa_signature sig;
struct short_channel_id scid;
u32 timestamp, fee_base_msat, fee_proportional_mill;
u64 htlc_minimum_msat;
u64 htlc_maximum_msat;
struct amount_msat htlc_minimum, htlc_maximum;
u8 message_flags, channel_flags;
u16 cltv_expiry_delta;
struct bitcoin_blkid chain_hash;
@ -667,8 +666,8 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
if (!fromwire_channel_update_option_channel_htlc_max(cu, &sig,
&chain_hash, &scid, &timestamp, &message_flags,
&channel_flags, &cltv_expiry_delta,
&htlc_minimum_msat, &fee_base_msat,
&fee_proportional_mill, &htlc_maximum_msat)) {
&htlc_minimum, &fee_base_msat,
&fee_proportional_mill, &htlc_maximum)) {
return bad_req_fmt(conn, c, msg_in, "Bad inner channel_update");
}
if (tal_count(cu) < offset)
@ -682,9 +681,9 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
cu = towire_channel_update_option_channel_htlc_max(tmpctx, &sig, &chain_hash,
&scid, timestamp, message_flags, channel_flags,
cltv_expiry_delta, htlc_minimum_msat,
cltv_expiry_delta, htlc_minimum,
fee_base_msat, fee_proportional_mill,
htlc_maximum_msat);
htlc_maximum);
return req_reply(conn, c, take(towire_hsm_cupdate_sig_reply(NULL, cu)));
}

43
openingd/openingd.c

@ -484,12 +484,12 @@ static u8 *funder_channel(struct state *state,
msg = towire_open_channel(NULL,
&state->chainparams->genesis_blockhash,
&state->channel_id,
state->funding.satoshis,
state->push_msat.millisatoshis,
state->localconf.dust_limit.satoshis,
state->localconf.max_htlc_value_in_flight.millisatoshis,
state->localconf.channel_reserve.satoshis,
state->localconf.htlc_minimum.millisatoshis,
state->funding,
state->push_msat,
state->localconf.dust_limit,
state->localconf.max_htlc_value_in_flight,
state->localconf.channel_reserve,
state->localconf.htlc_minimum,
state->feerate_per_kw,
state->localconf.to_self_delay,
state->localconf.max_accepted_htlcs,
@ -519,12 +519,10 @@ static u8 *funder_channel(struct state *state,
* valid DER-encoded compressed secp256k1 pubkeys.
*/
if (!fromwire_accept_channel(msg, &id_in,
&state->remoteconf.dust_limit.satoshis,
&state->remoteconf
.max_htlc_value_in_flight.millisatoshis,
&state->remoteconf
.channel_reserve.satoshis,
&state->remoteconf.htlc_minimum.millisatoshis,
&state->remoteconf.dust_limit,
&state->remoteconf.max_htlc_value_in_flight,
&state->remoteconf.channel_reserve,
&state->remoteconf.htlc_minimum,
&minimum_depth,
&state->remoteconf.to_self_delay,
&state->remoteconf.max_accepted_htlcs,
@ -853,12 +851,12 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
*/
if (!fromwire_open_channel(open_channel_msg, &chain_hash,
&state->channel_id,
&state->funding.satoshis,
&state->push_msat.millisatoshis,
&state->remoteconf.dust_limit.satoshis,
&state->remoteconf.max_htlc_value_in_flight.millisatoshis,
&state->remoteconf.channel_reserve.satoshis,
&state->remoteconf.htlc_minimum.millisatoshis,
&state->funding,
&state->push_msat,
&state->remoteconf.dust_limit,
&state->remoteconf.max_htlc_value_in_flight,
&state->remoteconf.channel_reserve,
&state->remoteconf.htlc_minimum,
&state->feerate_per_kw,
&state->remoteconf.to_self_delay,
&state->remoteconf.max_accepted_htlcs,
@ -991,11 +989,10 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
/* OK, we accept! */
msg = towire_accept_channel(NULL, &state->channel_id,
state->localconf.dust_limit.satoshis,
state->localconf
.max_htlc_value_in_flight.millisatoshis,
state->localconf.channel_reserve.satoshis,
state->localconf.htlc_minimum.millisatoshis,
state->localconf.dust_limit,
state->localconf.max_htlc_value_in_flight,
state->localconf.channel_reserve,
state->localconf.htlc_minimum,
state->minimum_depth,
state->localconf.to_self_delay,
state->localconf.max_accepted_htlcs,

8
tools/generate-wire.py

@ -22,6 +22,8 @@ type2size = {
'struct bitcoin_blkid': 32,
'struct bitcoin_txid': 32,
'struct secret': 32,
'struct amount_msat': 8,
'struct amount_sat': 8,
'u64': 8,
'u32': 4,
'u16': 2,
@ -79,7 +81,9 @@ typemap = {
('channel_announcement', 'short_channel_id'): FieldType('struct short_channel_id'),
('channel_update', 'short_channel_id'): FieldType('struct short_channel_id'),
('revoke_and_ack', 'per_commitment_secret'): FieldType('struct secret'),
('channel_reestablish_option_data_loss_protect', 'your_last_per_commitment_secret'): FieldType('struct secret')
('channel_reestablish_option_data_loss_protect', 'your_last_per_commitment_secret'): FieldType('struct secret'),
('channel_update', 'fee_base_msat'): FieldType('u32'),
('final_incorrect_htlc_amount', 'incoming_htlc_amt'): FieldType('struct amount_msat'),
}
# Partial names that map to a datatype
@ -90,6 +94,8 @@ partialtypemap = {
'chain_hash': FieldType('struct bitcoin_blkid'),
'funding_txid': FieldType('struct bitcoin_txid'),
'pad': FieldType('pad'),
'msat': FieldType('struct amount_msat'),
'satoshis': FieldType('struct amount_sat'),
}
# Size to typename match

10
wire/peer_wire.c

@ -83,6 +83,8 @@ bool is_unknown_msg_discardable(const u8 *cursor)
/* Extract channel_id from various packets, return true if possible. */
bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
{
struct amount_sat ignored_sat;
struct amount_msat ignored_msat;
u64 ignored_u64;
u32 ignored_u32;
u16 ignored_u16;
@ -94,10 +96,10 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
&ignored_u64, &ignored_u64))
return true;
if (fromwire_open_channel(in_pkt, &ignored_chainhash,
channel_id, &ignored_u64,
&ignored_u64, &ignored_u64,
&ignored_u64, &ignored_u64,
&ignored_u64, &ignored_u32,
channel_id, &ignored_sat,
&ignored_msat, &ignored_sat,
&ignored_msat, &ignored_sat,
&ignored_msat, &ignored_u32,
&ignored_u16, &ignored_u16,
&ignored_pubkey, &ignored_pubkey,
&ignored_pubkey, &ignored_pubkey,

30
wire/test/run-peer-wire.c

@ -81,7 +81,7 @@ struct msg_error {
};
struct msg_closing_signed {
struct channel_id channel_id;
u64 fee_satoshis;
struct amount_sat fee_satoshis;
secp256k1_ecdsa_signature signature;
};
struct msg_funding_created {
@ -92,10 +92,10 @@ struct msg_funding_created {
};
struct msg_accept_channel {
struct channel_id temporary_channel_id;
u64 dust_limit_satoshis;
u64 max_htlc_value_in_flight_msat;
u64 channel_reserve_satoshis;
u64 htlc_minimum_msat;
struct amount_sat dust_limit_satoshis;
struct amount_msat max_htlc_value_in_flight_msat;
struct amount_sat channel_reserve_satoshis;
struct amount_msat htlc_minimum_msat;
u32 minimum_depth;
u16 to_self_delay;
u16 max_accepted_htlcs;
@ -130,7 +130,7 @@ struct msg_channel_update {
u8 message_flags;
u8 channel_flags;
u16 expiry;
u64 htlc_minimum_msat;
struct amount_msat htlc_minimum_msat;
u32 fee_base_msat;
u32 fee_proportional_millionths;
struct bitcoin_blkid chain_hash;
@ -142,10 +142,10 @@ struct msg_channel_update_opt_htlc_max {
u8 message_flags;
u8 channel_flags;
u16 expiry;
u64 htlc_minimum_msat;
struct amount_msat htlc_minimum_msat;
u32 fee_base_msat;
u32 fee_proportional_millionths;
u64 htlc_maximum_msat;
struct amount_msat htlc_maximum_msat;
struct bitcoin_blkid chain_hash;
struct short_channel_id short_channel_id;
};
@ -176,12 +176,12 @@ struct msg_node_announcement {
struct msg_open_channel {
struct bitcoin_blkid chain_hash;
struct channel_id temporary_channel_id;
u64 funding_satoshis;
u64 push_msat;
u64 dust_limit_satoshis;
u64 max_htlc_value_in_flight_msat;
u64 channel_reserve_satoshis;
u64 htlc_minimum_msat;
struct amount_sat funding_satoshis;
struct amount_msat push_msat;
struct amount_sat dust_limit_satoshis;
struct amount_msat max_htlc_value_in_flight_msat;
struct amount_sat channel_reserve_satoshis;
struct amount_msat htlc_minimum_msat;
u32 feerate_per_kw;
u16 to_self_delay;
u16 max_accepted_htlcs;
@ -218,7 +218,7 @@ struct msg_init {
struct msg_update_add_htlc {
struct channel_id channel_id;
u64 id;
u64 amount_msat;
struct amount_msat amount_msat;
u32 expiry;
struct sha256 payment_hash;
u8 onion_routing_packet[TOTAL_PACKET_SIZE];

Loading…
Cancel
Save