MCPcopy Create free account
hub / github.com/ElementsProject/lightning / get_txout

Function get_txout

lightningd/gossip_control.c:78–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78static void get_txout(struct subd *gossip, const u8 *msg)
79{
80 struct short_channel_id *scid = tal(gossip, struct short_channel_id);
81 struct outpoint *op;
82 u32 blockheight;
83 struct chain_topology *topo = gossip->ld->topology;
84
85 if (!fromwire_gossipd_get_txout(msg, scid))
86 fatal("Gossip gave bad GOSSIP_GET_TXOUT message %s",
87 tal_hex(msg, msg));
88
89 /* FIXME: Block less than 6 deep? */
90 blockheight = short_channel_id_blocknum(scid);
91
92 op = wallet_outpoint_for_scid(gossip->ld->wallet, scid, scid);
93
94 if (op) {
95 subd_send_msg(gossip,
96 towire_gossipd_get_txout_reply(
97 scid, scid, op->sat, op->scriptpubkey));
98 tal_free(scid);
99 } else if (wallet_have_block(gossip->ld->wallet, blockheight)) {
100 /* We should have known about this outpoint since its header
101 * is in the DB. The fact that we don't means that this is
102 * either a spent outpoint or an invalid one. Return a
103 * failure. */
104 subd_send_msg(gossip, take(towire_gossipd_get_txout_reply(
105 NULL, scid, AMOUNT_SAT(0), NULL)));
106 tal_free(scid);
107 } else {
108 bitcoind_getfilteredblock(topo->bitcoind, short_channel_id_blocknum(scid), got_filteredblock, scid);
109 }
110}
111
112static void handle_local_channel_update(struct lightningd *ld, const u8 *msg)
113{

Callers 1

gossip_msgFunction · 0.85

Calls 7

tal_hexFunction · 0.85
wallet_outpoint_for_scidFunction · 0.85
tal_freeFunction · 0.85
wallet_have_blockFunction · 0.85
fatalFunction · 0.70
subd_send_msgFunction · 0.70

Tested by

no test coverage detected