gossip: Pass output value to gossipd

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-03-05 23:25:00 +01:00 committed by Rusty Russell
parent cb4ba9bf4f
commit a8e553098a
3 changed files with 14 additions and 7 deletions

View File

@ -1813,8 +1813,9 @@ static struct io_plan *handle_txout_reply(struct io_conn *conn,
{
struct short_channel_id scid;
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);
if (handle_pending_cannouncement(daemon->rstate, &scid, outscript))

View File

@ -191,6 +191,7 @@ gossip_get_txout,,short_channel_id,struct short_channel_id
# master->gossipd here is the output, or empty if none.
gossip_get_txout_reply,3118
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,,outscript,len*u8

1 #include <common/cryptomsg.h>
191 gossipctl_peer_disconnect_replyfail,,isconnected,bool
192
193
194
195
196
197

View File

@ -66,15 +66,19 @@ static void got_txout(struct bitcoind *bitcoind,
struct short_channel_id *scid)
{
const u8 *script;
u64 satoshis = 0;
/* output will be NULL if it wasn't found */
if (output)
if (output) {
script = output->script;
else
satoshis = output->amount;
} else {
script = NULL;
}
subd_send_msg(bitcoind->ld->gossip,
towire_gossip_get_txout_reply(scid, scid, script));
subd_send_msg(
bitcoind->ld->gossip,
towire_gossip_get_txout_reply(scid, scid, satoshis, script));
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);
if (op) {
subd_send_msg(gossip, towire_gossip_get_txout_reply(
scid, scid, op->scriptpubkey));
subd_send_msg(gossip,
towire_gossip_get_txout_reply(
scid, scid, op->satoshis, op->scriptpubkey));
tal_free(scid);
} else {
bitcoind_getoutput(gossip->ld->topology->bitcoind,