routing: Use 64-bit msatoshi for messages to and from routing.

Internally both payment and routing use 64-bit, but the interface
between them used 32-bit.
Since both components already support 64-bit we should use that.
This commit is contained in:
ZmnSCPxj 2018-04-09 13:31:23 +00:00 committed by Christian Decker
parent 0ba687732f
commit 86290b54d4
7 changed files with 12 additions and 11 deletions

View File

@ -1100,7 +1100,8 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
u8 *msg)
{
struct pubkey source, destination;
u32 msatoshi, final_cltv;
u64 msatoshi;
u32 final_cltv;
u16 riskfactor;
u8 *out;
struct route_hop *hops;
@ -1111,7 +1112,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
&source, &destination,
&msatoshi, &riskfactor, &final_cltv,
&fuzz, &seed);
status_trace("Trying to find a route from %s to %s for %d msatoshi",
status_trace("Trying to find a route from %s to %s for %"PRIu64" msatoshi",
pubkey_to_hexstr(tmpctx, &source),
pubkey_to_hexstr(tmpctx, &destination), msatoshi);

View File

@ -104,7 +104,7 @@ gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry
gossip_getroute_request,3006
gossip_getroute_request,,source,struct pubkey
gossip_getroute_request,,destination,struct pubkey
gossip_getroute_request,,msatoshi,u32
gossip_getroute_request,,msatoshi,u64
gossip_getroute_request,,riskfactor,u16
gossip_getroute_request,,final_cltv,u32
gossip_getroute_request,,fuzz,double

1 #include <common/cryptomsg.h>
104 gossip_getchannels_request,,short_channel_id,num*struct short_channel_id
105 gossip_getchannels_reply,3107
106 gossip_getchannels_reply,,num_channels,u16
107 gossip_getchannels_reply,,nodes,num_channels*struct gossip_getchannels_entry
108 # Ping/pong test. Waits for a reply if it expects one.
109 gossip_ping,3008
110 gossip_ping,,id,struct pubkey

View File

@ -1233,7 +1233,7 @@ u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node_ann)
struct route_hop *get_route(const tal_t *ctx, struct routing_state *rstate,
const struct pubkey *source,
const struct pubkey *destination,
const u32 msatoshi, double riskfactor,
const u64 msatoshi, double riskfactor,
u32 final_cltv,
double fuzz, const struct siphash_seed *base_seed)
{

View File

@ -176,7 +176,7 @@ get_channel(const struct routing_state *rstate,
struct route_hop {
struct short_channel_id channel_id;
struct pubkey nodeid;
u32 amount;
u64 amount;
u32 delay;
};
@ -238,7 +238,7 @@ struct node *get_node(struct routing_state *rstate, const struct pubkey *id);
struct route_hop *get_route(const tal_t *ctx, struct routing_state *rstate,
const struct pubkey *source,
const struct pubkey *destination,
const u32 msatoshi, double riskfactor,
const u64 msatoshi, double riskfactor,
u32 final_cltv,
double fuzz,
const struct siphash_seed *base_seed);

View File

@ -54,14 +54,14 @@ void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry)
{
fromwire_pubkey(pptr, max, &entry->nodeid);
fromwire_short_channel_id(pptr, max, &entry->channel_id);
entry->amount = fromwire_u32(pptr, max);
entry->amount = fromwire_u64(pptr, max);
entry->delay = fromwire_u32(pptr, max);
}
void towire_route_hop(u8 **pptr, const struct route_hop *entry)
{
towire_pubkey(pptr, &entry->nodeid);
towire_short_channel_id(pptr, &entry->channel_id);
towire_u32(pptr, entry->amount);
towire_u64(pptr, entry->amount);
towire_u32(pptr, entry->delay);
}

View File

@ -741,7 +741,7 @@ send_payment(const tal_t *ctx,
sizeof(struct sha256), &path_secrets);
onion = serialize_onionpacket(tmpctx, packet);
log_info(ld->log, "Sending %u over %zu hops to deliver %"PRIu64"",
log_info(ld->log, "Sending %"PRIu64" over %zu hops to deliver %"PRIu64"",
route[0].amount, n_hops, msatoshi);
failcode = send_htlc_out(channel, route[0].amount,
@ -969,7 +969,7 @@ static void json_sendpay(struct command *cmd,
tal_resize(&route, n_hops + 1);
/* What that hop will forward */
if (!json_tok_number(buffer, amttok, &route[n_hops].amount)) {
if (!json_tok_u64(buffer, amttok, &route[n_hops].amount)) {
command_fail(cmd, "Route %zu invalid msatoshi",
n_hops);
return;

View File

@ -362,7 +362,7 @@ static char const *stringify_route(const tal_t *ctx, struct route_hop *route)
size_t i;
char *rv = tal_strdup(ctx, "us");
for (i = 0; i < tal_count(route); ++i)
tal_append_fmt(&rv, " -> %s (%"PRIu32"msat, %"PRIu32"blk) -> %s",
tal_append_fmt(&rv, " -> %s (%"PRIu64"msat, %"PRIu32"blk) -> %s",
type_to_string(ctx, struct short_channel_id, &route[i].channel_id),
route[i].amount, route[i].delay,
type_to_string(ctx, struct pubkey, &route[i].nodeid));