Browse Source

gossip: Pass output value to gossipd

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
a8e553098a
  1. 3
      gossipd/gossip.c
  2. 1
      gossipd/gossip_wire.csv
  3. 17
      lightningd/gossip_control.c

3
gossipd/gossip.c

@ -1813,8 +1813,9 @@ static struct io_plan *handle_txout_reply(struct io_conn *conn,
{ {
struct short_channel_id scid; struct short_channel_id scid;
u8 *outscript; u8 *outscript;
u64 satoshis;
if (!fromwire_gossip_get_txout_reply(msg, msg, &scid, &outscript)) if (!fromwire_gossip_get_txout_reply(msg, msg, &scid, &satoshis, &outscript))
master_badmsg(WIRE_GOSSIP_GET_TXOUT_REPLY, msg); master_badmsg(WIRE_GOSSIP_GET_TXOUT_REPLY, msg);
if (handle_pending_cannouncement(daemon->rstate, &scid, outscript)) if (handle_pending_cannouncement(daemon->rstate, &scid, outscript))

1
gossipd/gossip_wire.csv

@ -191,6 +191,7 @@ gossip_get_txout,,short_channel_id,struct short_channel_id
# master->gossipd here is the output, or empty if none. # master->gossipd here is the output, or empty if none.
gossip_get_txout_reply,3118 gossip_get_txout_reply,3118
gossip_get_txout_reply,,short_channel_id,struct short_channel_id gossip_get_txout_reply,,short_channel_id,struct short_channel_id
gossip_get_txout_reply,,satoshis,u64
gossip_get_txout_reply,,len,u16 gossip_get_txout_reply,,len,u16
gossip_get_txout_reply,,outscript,len*u8 gossip_get_txout_reply,,outscript,len*u8

Can't render this file because it has a wrong number of fields in line 6.

17
lightningd/gossip_control.c

@ -66,15 +66,19 @@ static void got_txout(struct bitcoind *bitcoind,
struct short_channel_id *scid) struct short_channel_id *scid)
{ {
const u8 *script; const u8 *script;
u64 satoshis = 0;
/* output will be NULL if it wasn't found */ /* output will be NULL if it wasn't found */
if (output) if (output) {
script = output->script; script = output->script;
else satoshis = output->amount;
} else {
script = NULL; script = NULL;
}
subd_send_msg(bitcoind->ld->gossip, subd_send_msg(
towire_gossip_get_txout_reply(scid, scid, script)); bitcoind->ld->gossip,
towire_gossip_get_txout_reply(scid, scid, satoshis, script));
tal_free(scid); tal_free(scid);
} }
@ -92,8 +96,9 @@ static void get_txout(struct subd *gossip, const u8 *msg)
op = wallet_outpoint_for_scid(gossip->ld->wallet, scid, scid); op = wallet_outpoint_for_scid(gossip->ld->wallet, scid, scid);
if (op) { if (op) {
subd_send_msg(gossip, towire_gossip_get_txout_reply( subd_send_msg(gossip,
scid, scid, op->scriptpubkey)); towire_gossip_get_txout_reply(
scid, scid, op->satoshis, op->scriptpubkey));
tal_free(scid); tal_free(scid);
} else { } else {
bitcoind_getoutput(gossip->ld->topology->bitcoind, bitcoind_getoutput(gossip->ld->topology->bitcoind,

Loading…
Cancel
Save