Browse Source

closingd: convert to new wire generation style.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
fe8564555f
  1. 12
      closingd/Makefile
  2. 45
      closingd/closing_wire.csv
  3. 14
      closingd/closingd.c
  4. 45
      closingd/closingd_wire.csv
  5. 22
      lightningd/closing_control.c
  6. 1
      lightningd/lightningd.c
  7. 79
      lightningd/onchain_control.c
  8. 2
      lightningd/onchain_control.h
  9. 6
      lightningd/peer_control.c
  10. 5
      lightningd/peer_htlcs.c
  11. 12
      lightningd/test/run-invoice-select-inchan.c
  12. 22
      onchaind/Makefile
  13. 136
      onchaind/onchain_wire.csv
  14. 46
      onchaind/onchaind.c
  15. 2
      onchaind/onchaind_wire.c
  16. 136
      onchaind/onchaind_wire.csv
  17. 6
      onchaind/onchaind_wire.h
  18. 114
      onchaind/test/run-grind_feerate-bug.c
  19. 108
      onchaind/test/run-grind_feerate.c
  20. 18
      wallet/test/run-wallet.c
  21. 4
      wallet/wallet.c
  22. 2
      wallet/wallet.h

12
closingd/Makefile

@ -10,7 +10,7 @@ closingd-all: lightningd/lightning_closingd
# closingd needs these:
LIGHTNINGD_CLOSING_HEADERS_GEN := \
closingd/gen_closing_wire.h
closingd/closingd_wiregen.h
LIGHTNINGD_CLOSING_HEADERS_NOGEN :=
@ -30,9 +30,9 @@ LIGHTNINGD_CLOSING_CONTROL_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS)
LIGHTNINGD_CLOSING_CONTROL_SRC := $(LIGHTNINGD_CLOSING_HEADERS:.h=.c)
LIGHTNINGD_CLOSING_CONTROL_OBJS := $(LIGHTNINGD_CLOSING_CONTROL_SRC:.c=.o)
LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC))
LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/%wiregen.c, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC))
LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC))
LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/%wiregen.c, $(LIGHTNINGD_CLOSING_SRC))
# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CLOSING_HEADERS_GEN)
@ -84,12 +84,6 @@ CLOSINGD_COMMON_OBJS := \
common/wireaddr.o \
gossipd/gossipd_peerd_wiregen.o
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) --page header $@ closing_wire_type < closingd/closing_wire.csv > $@
closingd/gen_closing_wire.c: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) --page impl ${@:.c=.h} closing_wire_type < closingd/closing_wire.csv > $@
LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) $(LIGHTNINGD_CLOSING_GEN_SRC:.c=.o)
lightningd/lightning_closingd: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)

45
closingd/closing_wire.csv

@ -1,45 +0,0 @@
#include <bitcoin/tx.h>
#include <common/cryptomsg.h>
#include <common/htlc_wire.h>
#include <common/per_peer_state.h>
# Begin! (passes peer fd, gossipd-client fd)
msgtype,closing_init,2001
msgdata,closing_init,chainparams,chainparams,
msgdata,closing_init,pps,per_peer_state,
msgdata,closing_init,funding_txid,bitcoin_txid,
msgdata,closing_init,funding_txout,u16,
msgdata,closing_init,funding_satoshi,amount_sat,
msgdata,closing_init,local_fundingkey,pubkey,
msgdata,closing_init,remote_fundingkey,pubkey,
msgdata,closing_init,opener,enum side,
msgdata,closing_init,local_sat,amount_sat,
msgdata,closing_init,remote_sat,amount_sat,
msgdata,closing_init,our_dust_limit,amount_sat,
msgdata,closing_init,min_fee_satoshi,amount_sat,
msgdata,closing_init,fee_limit_satoshi,amount_sat,
msgdata,closing_init,initial_fee_satoshi,amount_sat,
msgdata,closing_init,local_scriptpubkey_len,u16,
msgdata,closing_init,local_scriptpubkey,u8,local_scriptpubkey_len
msgdata,closing_init,remote_scriptpubkey_len,u16,
msgdata,closing_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
msgdata,closing_init,fee_negotiation_step,u64,
msgdata,closing_init,fee_negotiation_step_unit,u8,
msgdata,closing_init,reconnected,bool,
msgdata,closing_init,next_index_local,u64,
msgdata,closing_init,next_index_remote,u64,
msgdata,closing_init,revocations_received,u64,
msgdata,closing_init,channel_reestablish_len,u16,
msgdata,closing_init,channel_reestablish,u8,channel_reestablish_len
msgdata,closing_init,last_remote_secret,secret,
msgdata,closing_init,dev_fast_gossip,bool,
# We received an offer, save signature.
msgtype,closing_received_signature,2002
msgdata,closing_received_signature,signature,bitcoin_signature,
msgdata,closing_received_signature,tx,bitcoin_tx,
msgtype,closing_received_signature_reply,2102
msgdata,closing_received_signature_reply,closing_txid,bitcoin_txid,
# Negotiations complete, we're exiting.
msgtype,closing_complete,2004
Can't render this file because it has a wrong number of fields in line 5.

14
closingd/closingd.c

@ -1,6 +1,6 @@
#include <bitcoin/script.h>
#include <ccan/fdpass/fdpass.h>
#include <closingd/gen_closing_wire.h>
#include <closingd/closingd_wiregen.h>
#include <common/close_tx.h>
#include <common/closing_fee.h>
#include <common/crypto_sync.h>
@ -300,7 +300,7 @@ static void tell_master_their_offer(const struct bitcoin_signature *their_sig,
const struct bitcoin_tx *tx,
struct bitcoin_txid *tx_id)
{
u8 *msg = towire_closing_received_signature(NULL, their_sig, tx);
u8 *msg = towire_closingd_received_signature(NULL, their_sig, tx);
if (!wire_sync_write(REQ_FD, take(msg)))
status_failed(STATUS_FAIL_MASTER_IO,
"Writing received to master: %s",
@ -308,8 +308,8 @@ static void tell_master_their_offer(const struct bitcoin_signature *their_sig,
/* Wait for master to ack, to make sure it's in db. */
msg = wire_sync_read(NULL, REQ_FD);
if (!fromwire_closing_received_signature_reply(msg, tx_id))
master_badmsg(WIRE_CLOSING_RECEIVED_SIGNATURE_REPLY, msg);
if (!fromwire_closingd_received_signature_reply(msg, tx_id))
master_badmsg(WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY, msg);
tal_free(msg);
}
@ -625,7 +625,7 @@ int main(int argc, char *argv[])
status_setup_sync(REQ_FD);
msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_closing_init(ctx, msg,
if (!fromwire_closingd_init(ctx, msg,
&chainparams,
&pps,
&funding_txid, &funding_txout,
@ -649,7 +649,7 @@ int main(int argc, char *argv[])
&channel_reestablish,
&last_remote_per_commit_secret,
&dev_fast_gossip))
master_badmsg(WIRE_CLOSING_INIT, msg);
master_badmsg(WIRE_CLOSINGD_INIT, msg);
/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = hsmd */
per_peer_state_set_fds(pps, 3, 4, 5);
@ -791,7 +791,7 @@ int main(int argc, char *argv[])
status_unusual("Closing and draining peerfd gave error: %s",
strerror(errno));
/* Sending the below will kill us! */
wire_sync_write(REQ_FD, take(towire_closing_complete(NULL)));
wire_sync_write(REQ_FD, take(towire_closingd_complete(NULL)));
tal_free(ctx);
daemon_shutdown();

45
closingd/closingd_wire.csv

@ -0,0 +1,45 @@
#include <bitcoin/tx.h>
#include <common/cryptomsg.h>
#include <common/htlc_wire.h>
#include <common/per_peer_state.h>
# Begin! (passes peer fd, gossipd-client fd)
msgtype,closingd_init,2001
msgdata,closingd_init,chainparams,chainparams,
msgdata,closingd_init,pps,per_peer_state,
msgdata,closingd_init,funding_txid,bitcoin_txid,
msgdata,closingd_init,funding_txout,u16,
msgdata,closingd_init,funding_satoshi,amount_sat,
msgdata,closingd_init,local_fundingkey,pubkey,
msgdata,closingd_init,remote_fundingkey,pubkey,
msgdata,closingd_init,opener,enum side,
msgdata,closingd_init,local_sat,amount_sat,
msgdata,closingd_init,remote_sat,amount_sat,
msgdata,closingd_init,our_dust_limit,amount_sat,
msgdata,closingd_init,min_fee_satoshi,amount_sat,
msgdata,closingd_init,fee_limit_satoshi,amount_sat,
msgdata,closingd_init,initial_fee_satoshi,amount_sat,
msgdata,closingd_init,local_scriptpubkey_len,u16,
msgdata,closingd_init,local_scriptpubkey,u8,local_scriptpubkey_len
msgdata,closingd_init,remote_scriptpubkey_len,u16,
msgdata,closingd_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
msgdata,closingd_init,fee_negotiation_step,u64,
msgdata,closingd_init,fee_negotiation_step_unit,u8,
msgdata,closingd_init,reconnected,bool,
msgdata,closingd_init,next_index_local,u64,
msgdata,closingd_init,next_index_remote,u64,
msgdata,closingd_init,revocations_received,u64,
msgdata,closingd_init,channel_reestablish_len,u16,
msgdata,closingd_init,channel_reestablish,u8,channel_reestablish_len
msgdata,closingd_init,last_remote_secret,secret,
msgdata,closingd_init,dev_fast_gossip,bool,
# We received an offer, save signature.
msgtype,closingd_received_signature,2002
msgdata,closingd_received_signature,signature,bitcoin_signature,
msgdata,closingd_received_signature,tx,bitcoin_tx,
msgtype,closingd_received_signature_reply,2102
msgdata,closingd_received_signature_reply,closing_txid,bitcoin_txid,
# Negotiations complete, we're exiting.
msgtype,closingd_complete,2004
Can't render this file because it has a wrong number of fields in line 5.

22
lightningd/closing_control.c

@ -1,6 +1,6 @@
#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
#include <closingd/gen_closing_wire.h>
#include <closingd/closingd_wiregen.h>
#include <common/close_tx.h>
#include <common/fee_states.h>
#include <common/initial_commit_tx.h>
@ -97,7 +97,7 @@ static void peer_received_closing_signature(struct channel *channel,
struct bitcoin_txid tx_id;
struct lightningd *ld = channel->peer->ld;
if (!fromwire_closing_received_signature(msg, msg, &sig, &tx)) {
if (!fromwire_closingd_received_signature(msg, msg, &sig, &tx)) {
channel_internal_error(channel, "Bad closing_received_signature %s",
tal_hex(msg, msg));
return;
@ -115,12 +115,12 @@ static void peer_received_closing_signature(struct channel *channel,
bitcoin_txid(channel->last_tx, &tx_id);
/* OK, you can continue now. */
subd_send_msg(channel->owner,
take(towire_closing_received_signature_reply(channel, &tx_id)));
take(towire_closingd_received_signature_reply(channel, &tx_id)));
}
static void peer_closing_complete(struct channel *channel, const u8 *msg)
{
if (!fromwire_closing_complete(msg)) {
if (!fromwire_closingd_complete(msg)) {
channel_internal_error(channel, "Bad closing_complete %s",
tal_hex(msg, msg));
return;
@ -142,20 +142,20 @@ static void peer_closing_complete(struct channel *channel, const u8 *msg)
static unsigned closing_msg(struct subd *sd, const u8 *msg, const int *fds UNUSED)
{
enum closing_wire_type t = fromwire_peektype(msg);
enum closingd_wire t = fromwire_peektype(msg);
switch (t) {
case WIRE_CLOSING_RECEIVED_SIGNATURE:
case WIRE_CLOSINGD_RECEIVED_SIGNATURE:
peer_received_closing_signature(sd->channel, msg);
break;
case WIRE_CLOSING_COMPLETE:
case WIRE_CLOSINGD_COMPLETE:
peer_closing_complete(sd->channel, msg);
break;
/* We send these, not receive them */
case WIRE_CLOSING_INIT:
case WIRE_CLOSING_RECEIVED_SIGNATURE_REPLY:
case WIRE_CLOSINGD_INIT:
case WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY:
break;
}
@ -192,7 +192,7 @@ void peer_start_closingd(struct channel *channel,
"lightning_closingd",
channel, &channel->peer->id,
channel->log, true,
closing_wire_type_name, closing_msg,
closingd_wire_name, closing_msg,
channel_errmsg,
channel_set_billboard,
take(&pps->peer_fd),
@ -278,7 +278,7 @@ void peer_start_closingd(struct channel *channel,
num_revocations-1);
return;
}
initmsg = towire_closing_init(tmpctx,
initmsg = towire_closingd_init(tmpctx,
chainparams,
pps,
&channel->funding_txid,

1
lightningd/lightningd.c

@ -79,7 +79,6 @@
#include <lightningd/memdump.h>
#include <lightningd/onchain_control.h>
#include <lightningd/options.h>
#include <onchaind/onchain_wire.h>
#include <signal.h>
#include <sodium.h>
#include <sys/resource.h>

79
lightningd/onchain_control.c

@ -12,7 +12,6 @@
#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
#include <lightningd/watch.h>
#include <onchaind/onchain_wire.h>
#include <wire/wire_sync.h>
/* We dump all the known preimages when onchaind starts up. */
@ -65,7 +64,7 @@ static void onchaind_tell_fulfill(struct channel *channel)
* The alternative is to double-count *every* ignored htlc output
* It's easier to delete than find a missing, but I'm banking on
* the rarity of failure here. (hahaha) */
msg = towire_onchain_known_preimage(channel, hin->preimage, false);
msg = towire_onchaind_known_preimage(channel, hin->preimage, false);
subd_send_msg(channel->owner, take(msg));
}
}
@ -85,7 +84,7 @@ static void onchain_tx_depth(struct channel *channel,
bool is_replay)
{
u8 *msg;
msg = towire_onchain_depth(channel, txid, depth, is_replay);
msg = towire_onchaind_depth(channel, txid, depth, is_replay);
subd_send_msg(channel->owner, take(msg));
}
@ -126,7 +125,7 @@ static enum watch_result onchain_tx_watched(struct lightningd *ld,
/* Store the channeltx so we can replay later */
wallet_channeltxs_add(ld->wallet, channel,
WIRE_ONCHAIN_DEPTH, txid, 0, blockheight);
WIRE_ONCHAIND_DEPTH, txid, 0, blockheight);
onchain_tx_depth(channel, txid, depth, false);
return KEEP_WATCHING;
@ -148,7 +147,7 @@ static void onchain_txo_spent(struct channel *channel, const struct bitcoin_tx *
watch_tx_and_outputs(channel, tx);
msg = towire_onchain_spent(channel, parts, input_num, blockheight, is_replay);
msg = towire_onchaind_spent(channel, parts, input_num, blockheight, is_replay);
subd_send_msg(channel->owner, take(msg));
}
@ -166,7 +165,7 @@ static enum watch_result onchain_txo_watched(struct channel *channel,
/* Store the channeltx so we can replay later */
wallet_channeltxs_add(channel->peer->ld->wallet, channel,
WIRE_ONCHAIN_SPENT, &txid, input_num,
WIRE_ONCHAIND_SPENT, &txid, input_num,
block->height);
onchain_txo_spent(channel, tx, input_num, block->height, false);
@ -201,7 +200,7 @@ static void handle_onchain_log_coin_move(struct channel *channel, const u8 *msg)
struct channel_id channel_id;
struct chain_coin_mvt *mvt = tal(NULL, struct chain_coin_mvt);
if (!fromwire_onchain_notify_coin_mvt(msg, mvt)) {
if (!fromwire_onchaind_notify_coin_mvt(msg, mvt)) {
channel_internal_error(channel, "Invalid onchain notify_coin_mvt");
return;
}
@ -221,7 +220,7 @@ static void handle_onchain_broadcast_tx(struct channel *channel, const u8 *msg)
struct bitcoin_txid txid;
enum wallet_tx_type type;
if (!fromwire_onchain_broadcast_tx(msg, msg, &tx, &type)) {
if (!fromwire_onchaind_broadcast_tx(msg, msg, &tx, &type)) {
channel_internal_error(channel, "Invalid onchain_broadcast_tx");
return;
}
@ -240,7 +239,7 @@ static void handle_onchain_unwatch_tx(struct channel *channel, const u8 *msg)
struct bitcoin_txid txid;
struct txwatch *txw;
if (!fromwire_onchain_unwatch_tx(msg, &txid)) {
if (!fromwire_onchaind_unwatch_tx(msg, &txid)) {
channel_internal_error(channel, "Invalid onchain_unwatch_tx");
return;
}
@ -257,7 +256,7 @@ static void handle_extracted_preimage(struct channel *channel, const u8 *msg)
{
struct preimage preimage;
if (!fromwire_onchain_extracted_preimage(msg, &preimage)) {
if (!fromwire_onchaind_extracted_preimage(msg, &preimage)) {
channel_internal_error(channel, "Invalid extracted_preimage");
return;
}
@ -269,7 +268,7 @@ static void handle_missing_htlc_output(struct channel *channel, const u8 *msg)
{
struct htlc_stub htlc;
if (!fromwire_onchain_missing_htlc_output(msg, &htlc)) {
if (!fromwire_onchaind_missing_htlc_output(msg, &htlc)) {
channel_internal_error(channel, "Invalid missing_htlc_output");
return;
}
@ -291,7 +290,7 @@ static void handle_onchain_htlc_timeout(struct channel *channel, const u8 *msg)
{
struct htlc_stub htlc;
if (!fromwire_onchain_htlc_timeout(msg, &htlc)) {
if (!fromwire_onchaind_htlc_timeout(msg, &htlc)) {
channel_internal_error(channel, "Invalid onchain_htlc_timeout");
return;
}
@ -330,7 +329,7 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg)
struct pubkey *commitment_point;
u8 *scriptPubkey;
if (!fromwire_onchain_add_utxo(
if (!fromwire_onchaind_add_utxo(
tmpctx, msg, &txid, &outnum, &commitment_point,
&amount, &blockheight, &scriptPubkey)) {
log_broken(channel->log,
@ -357,7 +356,7 @@ static void onchain_annotate_txout(struct channel *channel, const u8 *msg)
struct bitcoin_txid txid;
enum wallet_tx_type type;
u32 outnum;
if (!fromwire_onchain_annotate_txout(msg, &txid, &outnum, &type))
if (!fromwire_onchaind_annotate_txout(msg, &txid, &outnum, &type))
fatal("onchaind gave invalid onchain_annotate_txout "
"message: %s",
tal_hex(msg, msg));
@ -370,7 +369,7 @@ static void onchain_annotate_txin(struct channel *channel, const u8 *msg)
struct bitcoin_txid txid;
enum wallet_tx_type type;
u32 innum;
if (!fromwire_onchain_annotate_txin(msg, &txid, &innum, &type))
if (!fromwire_onchaind_annotate_txin(msg, &txid, &innum, &type))
fatal("onchaind gave invalid onchain_annotate_txin "
"message: %s",
tal_hex(msg, msg));
@ -380,61 +379,61 @@ static void onchain_annotate_txin(struct channel *channel, const u8 *msg)
static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds UNUSED)
{
enum onchain_wire_type t = fromwire_peektype(msg);
enum onchaind_wire t = fromwire_peektype(msg);
switch (t) {
case WIRE_ONCHAIN_INIT_REPLY:
case WIRE_ONCHAIND_INIT_REPLY:
handle_onchain_init_reply(sd->channel, msg);
break;
case WIRE_ONCHAIN_BROADCAST_TX:
case WIRE_ONCHAIND_BROADCAST_TX:
handle_onchain_broadcast_tx(sd->channel, msg);
break;
case WIRE_ONCHAIN_UNWATCH_TX:
case WIRE_ONCHAIND_UNWATCH_TX:
handle_onchain_unwatch_tx(sd->channel, msg);
break;
case WIRE_ONCHAIN_EXTRACTED_PREIMAGE:
case WIRE_ONCHAIND_EXTRACTED_PREIMAGE:
handle_extracted_preimage(sd->channel, msg);
break;
case WIRE_ONCHAIN_MISSING_HTLC_OUTPUT:
case WIRE_ONCHAIND_MISSING_HTLC_OUTPUT:
handle_missing_htlc_output(sd->channel, msg);
break;
case WIRE_ONCHAIN_HTLC_TIMEOUT:
case WIRE_ONCHAIND_HTLC_TIMEOUT:
handle_onchain_htlc_timeout(sd->channel, msg);
break;
case WIRE_ONCHAIN_ALL_IRREVOCABLY_RESOLVED:
case WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED:
handle_irrevocably_resolved(sd->channel, msg);
break;
case WIRE_ONCHAIN_ADD_UTXO:
case WIRE_ONCHAIND_ADD_UTXO:
onchain_add_utxo(sd->channel, msg);
break;
case WIRE_ONCHAIN_ANNOTATE_TXIN:
case WIRE_ONCHAIND_ANNOTATE_TXIN:
onchain_annotate_txin(sd->channel, msg);
break;
case WIRE_ONCHAIN_ANNOTATE_TXOUT:
case WIRE_ONCHAIND_ANNOTATE_TXOUT:
onchain_annotate_txout(sd->channel, msg);
break;
case WIRE_ONCHAIN_NOTIFY_COIN_MVT:
case WIRE_ONCHAIND_NOTIFY_COIN_MVT:
handle_onchain_log_coin_move(sd->channel, msg);
break;
/* We send these, not receive them */
case WIRE_ONCHAIN_INIT:
case WIRE_ONCHAIN_SPENT:
case WIRE_ONCHAIN_DEPTH:
case WIRE_ONCHAIN_HTLC:
case WIRE_ONCHAIN_KNOWN_PREIMAGE:
case WIRE_ONCHAIN_DEV_MEMLEAK:
case WIRE_ONCHAIN_DEV_MEMLEAK_REPLY:
case WIRE_ONCHAIND_INIT:
case WIRE_ONCHAIND_SPENT:
case WIRE_ONCHAIND_DEPTH:
case WIRE_ONCHAIND_HTLC:
case WIRE_ONCHAIND_KNOWN_PREIMAGE:
case WIRE_ONCHAIND_DEV_MEMLEAK:
case WIRE_ONCHAIND_DEV_MEMLEAK_REPLY:
break;
}
@ -523,7 +522,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
"lightning_onchaind",
channel, &channel->peer->id,
channel->log, false,
onchain_wire_type_name,
onchaind_wire_name,
onchain_msg,
onchain_error,
channel_set_billboard,
@ -588,7 +587,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
}
}
msg = towire_onchain_init(channel,
msg = towire_onchaind_init(channel,
&channel->their_shachain.chain,
chainparams,
channel->funding,
@ -634,7 +633,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
for (size_t i = 0; i < tal_count(stubs); i++) {
bool tell_immediate;
bool tell = tell_if_missing(channel, &stubs[i], &tell_immediate);
msg = towire_onchain_htlc(channel, &stubs[i],
msg = towire_onchaind_htlc(channel, &stubs[i],
tell, tell_immediate);
subd_send_msg(channel->owner, take(msg));
}
@ -666,18 +665,18 @@ void onchaind_replay_channels(struct lightningd *ld)
chan = channel_by_dbid(ld, onchaind_ids[i]);
for (size_t j = 0; j < tal_count(txs); j++) {
if (txs[j].type == WIRE_ONCHAIN_INIT) {
if (txs[j].type == WIRE_ONCHAIND_INIT) {
onchaind_funding_spent(chan, txs[j].tx,
txs[j].blockheight,
true);
} else if (txs[j].type == WIRE_ONCHAIN_SPENT) {
} else if (txs[j].type == WIRE_ONCHAIND_SPENT) {
onchain_txo_spent(chan, txs[j].tx,
txs[j].input_num,
txs[j].blockheight,
true);
} else if (txs[j].type == WIRE_ONCHAIN_DEPTH) {
} else if (txs[j].type == WIRE_ONCHAIND_DEPTH) {
onchain_tx_depth(chan, &txs[j].txid,
txs[j].depth, true);

2
lightningd/onchain_control.h

@ -3,7 +3,7 @@
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <lightningd/lightningd.h>
#include <onchaind/gen_onchain_wire.h>
#include <onchaind/onchaind_wiregen.h>
struct channel;
struct bitcoin_tx;

6
lightningd/peer_control.c

@ -1150,7 +1150,7 @@ static enum watch_result funding_spent(struct channel *channel,
bitcoin_txid(tx, &txid);
wallet_channeltxs_add(channel->peer->ld->wallet, channel,
WIRE_ONCHAIN_INIT, &txid, 0, block->height);
WIRE_ONCHAIND_INIT, &txid, 0, block->height);
return onchaind_funding_spent(channel, tx, block->height, false);
}
@ -2253,7 +2253,7 @@ static void onchaind_memleak_req_done(struct subd *onchaind,
bool found_leak;
tal_del_destructor2(onchaind, subd_died_forget_memleak, cmd);
if (!fromwire_onchain_dev_memleak_reply(msg, &found_leak)) {
if (!fromwire_onchaind_dev_memleak_reply(msg, &found_leak)) {
was_pending(command_fail(cmd, LIGHTNINGD,
"Bad onchain_dev_memleak"));
return;
@ -2292,7 +2292,7 @@ static void peer_memleak_req_next(struct command *cmd, struct channel *prev)
}
if (streq(c->owner->name, "onchaind")) {
subd_req(c, c->owner,
take(towire_onchain_dev_memleak(NULL)),
take(towire_onchaind_dev_memleak(NULL)),
-1, 0, onchaind_memleak_req_done, cmd);
tal_add_destructor2(c->owner,
subd_died_forget_memleak,

5
lightningd/peer_htlcs.c

@ -34,8 +34,7 @@
#include <lightningd/peer_htlcs.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
#include <onchaind/gen_onchain_wire.h>
#include <onchaind/onchain_wire.h>
#include <onchaind/onchaind_wiregen.h>
#include <wallet/wallet.h>
#include <wire/gen_onion_wire.h>
#include <wire/wire_sync.h>
@ -428,7 +427,7 @@ void fulfill_htlc(struct htlc_in *hin, const struct preimage *preimage)
}
if (channel_on_chain(channel)) {
msg = towire_onchain_known_preimage(hin, preimage, false);
msg = towire_onchaind_known_preimage(hin, preimage, false);
} else {
struct fulfilled_htlc fulfilled_htlc;
fulfilled_htlc.id = hin->key.id;

12
lightningd/test/run-invoice-select-inchan.c

@ -131,9 +131,9 @@ bool fromwire_hsmd_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_re
/* Generated stub for fromwire_node_id */
void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED)
{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); }
/* Generated stub for fromwire_onchain_dev_memleak_reply */
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_dev_memleak_reply */
bool fromwire_onchaind_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for get_block_height */
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
{ fprintf(stderr, "get_block_height called!\n"); abort(); }
@ -502,9 +502,9 @@ u8 *towire_hsmd_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEED
/* Generated stub for towire_node_id */
void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
{ fprintf(stderr, "towire_node_id called!\n"); abort(); }
/* Generated stub for towire_onchain_dev_memleak */
u8 *towire_onchain_dev_memleak(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchain_dev_memleak called!\n"); abort(); }
/* Generated stub for towire_onchaind_dev_memleak */
u8 *towire_onchaind_dev_memleak(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_dev_memleak called!\n"); abort(); }
/* Generated stub for towire_temporary_node_failure */
u8 *towire_temporary_node_failure(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_temporary_node_failure called!\n"); abort(); }

22
onchaind/Makefile

@ -13,31 +13,31 @@ onchaind/gen_onchain_types_names.h: onchaind/onchain_types.h ccan/ccan/cdump/too
# onchaind needs these:
LIGHTNINGD_ONCHAIN_HEADERS_GEN := \
onchaind/gen_onchain_wire.h \
onchaind/onchaind_wiregen.h \
onchaind/gen_onchain_types_names.h
LIGHTNINGD_ONCHAIN_HEADERS_NOGEN := \
onchaind/onchain_types.h \
onchaind/onchain_wire.h
onchaind/onchaind_wire.h
LIGHTNINGD_ONCHAIN_HEADERS := $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) $(LIGHTNINGD_ONCHAIN_HEADERS_NOGEN)
LIGHTNINGD_ONCHAIN_SRC := onchaind/onchaind.c \
onchaind/gen_onchain_wire.c \
onchaind/onchain_wire.c
onchaind/onchaind_wiregen.c \
onchaind/onchaind_wire.c
LIGHTNINGD_ONCHAIN_OBJS := $(LIGHTNINGD_ONCHAIN_SRC:.c=.o)
# Control daemon uses this:
LIGHTNINGD_ONCHAIN_CONTROL_HEADERS := \
onchaind/gen_onchain_wire.h \
onchaind/onchain_wire.h
onchaind/onchaind_wiregen.h \
onchaind/onchaind_wire.h
LIGHTNINGD_ONCHAIN_CONTROL_SRC := $(LIGHTNINGD_ONCHAIN_CONTROL_HEADERS:.h=.c)
LIGHTNINGD_ONCHAIN_CONTROL_OBJS := $(LIGHTNINGD_ONCHAIN_CONTROL_SRC:.c=.o)
LIGHTNINGD_ONCHAIN_GEN_SRC := $(filter onchaind/gen_%, $(LIGHTNINGD_ONCHAIN_SRC) $(LIGHTNINGD_ONCHAIN_CONTROL_SRC))
LIGHTNINGD_ONCHAIN_GEN_SRC := $(filter onchaind/%wiregen.c, $(LIGHTNINGD_ONCHAIN_SRC) $(LIGHTNINGD_ONCHAIN_CONTROL_SRC))
LIGHTNINGD_ONCHAIN_SRC_NOGEN := $(filter-out onchaind/gen_%, $(LIGHTNINGD_ONCHAIN_SRC))
LIGHTNINGD_ONCHAIN_SRC_NOGEN := $(filter-out onchaind/%wiregen.c, $(LIGHTNINGD_ONCHAIN_SRC))
# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_ONCHAIN_HEADERS_GEN)
@ -78,12 +78,6 @@ ONCHAIND_COMMON_OBJS := \
common/version.o \
common/wallet.o
onchaind/gen_onchain_wire.h: $(WIRE_GEN) onchaind/onchain_wire.csv
$(WIRE_GEN) --page header $@ onchain_wire_type < onchaind/onchain_wire.csv > $@
onchaind/gen_onchain_wire.c: $(WIRE_GEN) onchaind/onchain_wire.csv
$(WIRE_GEN) --page impl ${@:.c=.h} onchain_wire_type < onchaind/onchain_wire.csv > $@
LIGHTNINGD_ONCHAIN_OBJS := $(LIGHTNINGD_ONCHAIN_SRC:.c=.o) $(LIGHTNINGD_ONCHAIN_GEN_SRC:.c=.o)
# Make sure these depend on everything.

136
onchaind/onchain_wire.csv

@ -1,136 +0,0 @@
#include <bitcoin/tx_parts.h>
#include <common/coin_mvt.h>
#include <common/derive_basepoints.h>
#include <common/htlc_wire.h>
#include <common/wallet.h>
# Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
msgtype,onchain_init,5001
msgdata,onchain_init,shachain,shachain,
# This needs to be set explicitly since the same message also contains a
# transaction that we need to parse correctly.
msgdata,onchain_init,chainparams,chainparams,
msgdata,onchain_init,funding_amount_satoshi,amount_sat,
# Our current balance (of funding amount, not counting any pending htlcs)
msgdata,onchain_init,our_msat,amount_msat,
# Remote per commit point for committed tx.
msgdata,onchain_init,old_remote_per_commitment_point,pubkey,
# Remote per commit point for current tx (needed if we haven't got revoke_and_ack yet).
msgdata,onchain_init,remote_per_commitment_point,pubkey,
msgdata,onchain_init,local_to_self_delay,u32,
msgdata,onchain_init,remote_to_self_delay,u32,
msgdata,onchain_init,delayed_to_us_feerate,u32,
msgdata,onchain_init,htlc_feerate,u32,
msgdata,onchain_init,penalty_feerate,u32,
msgdata,onchain_init,local_dust_limit_satoshi,amount_sat,
# Gives an easy way to tell if it's our unilateral close or theirs...
msgdata,onchain_init,our_broadcast_txid,bitcoin_txid,
msgdata,onchain_init,local_scriptpubkey_len,u16,
msgdata,onchain_init,local_scriptpubkey,u8,local_scriptpubkey_len
msgdata,onchain_init,remote_scriptpubkey_len,u16,
msgdata,onchain_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
msgdata,onchain_init,ourwallet_pubkey,pubkey,
# We need these two for commit number obscurer
msgdata,onchain_init,opener,enum side,
msgdata,onchain_init,local_basepoints,basepoints,
msgdata,onchain_init,remote_basepoints,basepoints,
msgdata,onchain_init,tx_parts,tx_parts,
msgdata,onchain_init,locktime,u32,
msgdata,onchain_init,tx_blockheight,u32,
msgdata,onchain_init,reasonable_depth,u32,
msgdata,onchain_init,num_htlc_sigs,u16,
msgdata,onchain_init,htlc_signature,bitcoin_signature,num_htlc_sigs
msgdata,onchain_init,num_htlcs,u64,
msgdata,onchain_init,min_possible_feerate,u32,
msgdata,onchain_init,max_possible_feerate,u32,
msgdata,onchain_init,possible_remote_per_commit_point,?pubkey,
msgdata,onchain_init,local_funding_pubkey,pubkey,
msgdata,onchain_init,remote_funding_pubkey,pubkey,
msgdata,onchain_init,option_static_remotekey,bool,
msgdata,onchain_init,option_anchor_outputs,bool,
msgdata,onchain_init,is_replay,bool,
#include <onchaind/onchain_wire.h>
# This is all the HTLCs: one per message
msgtype,onchain_htlc,5002
msgdata,onchain_htlc,htlc,htlc_stub,
# If it's not in the commitment tx, tell us (immediately or htlc_missing_depth)
msgdata,onchain_htlc,tell_if_missing,bool,
msgdata,onchain_htlc,tell_immediately,bool,
# This says we're ready; give us preimages.
msgtype,onchain_init_reply,5101
# onchaind->master: Send out a tx.
msgtype,onchain_broadcast_tx,5003
msgdata,onchain_broadcast_tx,tx,bitcoin_tx,
msgdata,onchain_broadcast_tx,type,enum wallet_tx_type,
# master->onchaind: Notifier that an output has been spent by input_num of tx.
msgtype,onchain_spent,5004
msgdata,onchain_spent,tx,tx_parts,
msgdata,onchain_spent,input_num,u32,
msgdata,onchain_spent,blockheight,u32,
msgdata,onchain_spent,is_replay,bool,
# master->onchaind: We will receive more than one of these, as depth changes.
msgtype,onchain_depth,5005
msgdata,onchain_depth,txid,bitcoin_txid,
msgdata,onchain_depth,depth,u32,
msgdata,onchain_depth,is_replay,bool,
# onchaind->master: We don't want to watch this tx, or its outputs
msgtype,onchain_unwatch_tx,5006
msgdata,onchain_unwatch_tx,txid,bitcoin_txid,
# master->onchaind: We know HTLC preimage
msgtype,onchain_known_preimage,5007
msgdata,onchain_known_preimage,preimage,preimage,
msgdata,onchain_known_preimage,is_replay,bool,
# onchaind->master: We discovered HTLC preimage
msgtype,onchain_extracted_preimage,5008
msgdata,onchain_extracted_preimage,preimage,preimage,
# onchaind->master: this HTLC was missing from commit tx.
msgtype,onchain_missing_htlc_output,5009
msgdata,onchain_missing_htlc_output,htlc,htlc_stub,
# onchaind->master: this HTLC has timed out (after reasonable_depth)
msgtype,onchain_htlc_timeout,5010
msgdata,onchain_htlc_timeout,htlc,htlc_stub,
# onchaind->master: this peer can be forgotten
msgtype,onchain_all_irrevocably_resolved,5011
# onchaind->master: hey, I identified an UTXO you'll want to track
msgtype,onchain_add_utxo,5012
msgdata,onchain_add_utxo,prev_out_tx,bitcoin_txid,
msgdata,onchain_add_utxo,prev_out_index,u32,
msgdata,onchain_add_utxo,per_commit_point,?pubkey,
msgdata,onchain_add_utxo,value,amount_sat,
msgdata,onchain_add_utxo,blockheight,u32,
msgdata,onchain_add_utxo,len,u16,
msgdata,onchain_add_utxo,scriptpubkey,u8,len
# master -> onchaind: do you have a memleak?
msgtype,onchain_dev_memleak,5033
msgtype,onchain_dev_memleak_reply,5133
msgdata,onchain_dev_memleak_reply,leak,bool,
# Tell the main daemon what we've been watching, mainly used for transactions
# that we tracked automatically but only onchaind knows how to classify their
# transactions.
msgtype,onchain_annotate_txout,5035
msgdata,onchain_annotate_txout,txid,bitcoin_txid,
msgdata,onchain_annotate_txout,outnum,u32,
msgdata,onchain_annotate_txout,type,enum wallet_tx_type,
msgtype,onchain_annotate_txin,5036
msgdata,onchain_annotate_txin,txid,bitcoin_txid,
msgdata,onchain_annotate_txin,innum,u32,
msgdata,onchain_annotate_txin,type,enum wallet_tx_type,
msgtype,onchain_notify_coin_mvt,5037
msgdata,onchain_notify_coin_mvt,mvt,chain_coin_mvt,
Can't render this file because it has a wrong number of fields in line 7.

46
onchaind/onchaind.c

@ -23,8 +23,8 @@
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/channel_state.h>
#include <onchaind/gen_onchain_wire.h>
#include <onchaind/onchain_types.h>
#include <onchaind/onchaind_wiregen.h>
#include <stdio.h>
#include <unistd.h>
#include <wire/wire_sync.h>
@ -141,7 +141,7 @@ static bool wally_tx_output_scripteq(const struct wally_tx_output *out,
static void send_coin_mvt(struct chain_coin_mvt *mvt TAKES)
{
wire_sync_write(REQ_FD,
take(towire_onchain_notify_coin_mvt(NULL, mvt)));
take(towire_onchaind_notify_coin_mvt(NULL, mvt)));
if (taken(mvt))
tal_free(mvt);
@ -837,7 +837,7 @@ static void proposal_meets_depth(struct tracked_output *out, bool is_replay)
wire_sync_write(
REQ_FD,
take(towire_onchain_broadcast_tx(
take(towire_onchaind_broadcast_tx(
NULL, out->proposal->tx,
onchain_txtype_to_wallet_txtype(out->proposal->tx_type))));
@ -1164,7 +1164,7 @@ static void unwatch_txid(const struct bitcoin_txid *txid)
{
u8 *msg;
msg = towire_onchain_unwatch_tx(NULL, txid);
msg = towire_onchaind_unwatch_tx(NULL, txid);
wire_sync_write(REQ_FD, take(msg));
}
@ -1259,7 +1259,7 @@ static void handle_htlc_onchain_fulfill(struct tracked_output *out,
output_type_name(out->output_type),
type_to_string(tmpctx, struct preimage, &preimage));
wire_sync_write(REQ_FD,
take(towire_onchain_extracted_preimage(NULL,
take(towire_onchaind_extracted_preimage(NULL,
&preimage)));
}
@ -1390,14 +1390,14 @@ static void steal_htlc_tx(struct tracked_output *out,
static void onchain_annotate_txout(const struct bitcoin_txid *txid, u32 outnum,
enum wallet_tx_type type)
{
wire_sync_write(REQ_FD, take(towire_onchain_annotate_txout(
wire_sync_write(REQ_FD, take(towire_onchaind_annotate_txout(
tmpctx, txid, outnum, type)));
}
static void onchain_annotate_txin(const struct bitcoin_txid *txid, u32 innum,
enum wallet_tx_type type)
{
wire_sync_write(REQ_FD, take(towire_onchain_annotate_txin(
wire_sync_write(REQ_FD, take(towire_onchaind_annotate_txin(
tmpctx, txid, innum, type)));
}
@ -1568,7 +1568,7 @@ static void update_resolution_depth(struct tracked_output *out, u32 depth)
tx_type_name(out->tx_type),
output_type_name(out->output_type),
depth);
msg = towire_onchain_htlc_timeout(out, &out->htlc);
msg = towire_onchaind_htlc_timeout(out, &out->htlc);
wire_sync_write(REQ_FD, take(msg));
}
out->resolved->depth = depth;
@ -1776,7 +1776,7 @@ static bool handle_dev_memleak(struct tracked_output **outs, const u8 *msg)
struct htable *memtable;
bool found_leak;
if (!fromwire_onchain_dev_memleak(msg))
if (!fromwire_onchaind_dev_memleak(msg))
return false;
memtable = memleak_enter_allocations(tmpctx, msg, msg);
@ -1786,7 +1786,7 @@ static bool handle_dev_memleak(struct tracked_output **outs, const u8 *msg)
found_leak = dump_memleak(memtable);
wire_sync_write(REQ_FD,
take(towire_onchain_dev_memleak_reply(NULL,
take(towire_onchaind_dev_memleak_reply(NULL,
found_leak)));
return true;
}
@ -1819,14 +1819,14 @@ static void wait_for_resolved(struct tracked_output **outs)
struct tx_parts *tx_parts;
status_debug("Got new message %s",
onchain_wire_type_name(fromwire_peektype(msg)));
onchaind_wire_name(fromwire_peektype(msg)));
if (fromwire_onchain_depth(msg, &txid, &depth, &is_replay))
if (fromwire_onchaind_depth(msg, &txid, &depth, &is_replay))
tx_new_depth(outs, &txid, depth, is_replay);
else if (fromwire_onchain_spent(msg, msg, &tx_parts, &input_num,
else if (fromwire_onchaind_spent(msg, msg, &tx_parts, &input_num,
&tx_blockheight, &is_replay)) {
output_spent(&outs, tx_parts, input_num, tx_blockheight, is_replay);
} else if (fromwire_onchain_known_preimage(msg, &preimage, &is_replay))
} else if (fromwire_onchaind_known_preimage(msg, &preimage, &is_replay))
handle_preimage(outs, &preimage, is_replay);
else if (!handle_dev_memleak(outs, msg))
master_badmsg(-1, msg);
@ -1837,13 +1837,13 @@ static void wait_for_resolved(struct tracked_output **outs)
}
wire_sync_write(REQ_FD,
take(towire_onchain_all_irrevocably_resolved(outs)));
take(towire_onchaind_all_irrevocably_resolved(outs)));
}
static void init_reply(const char *what)
{
/* Send init_reply first, so billboard gets credited to ONCHAIND */
wire_sync_write(REQ_FD, take(towire_onchain_init_reply(NULL)));
wire_sync_write(REQ_FD, take(towire_onchaind_init_reply(NULL)));
peer_billboard(true, what);
}
@ -2151,7 +2151,7 @@ static void note_missing_htlcs(u8 **htlc_scripts,
if (!tell_if_missing[i])
continue;
msg = towire_onchain_missing_htlc_output(missing_htlc_msgs,
msg = towire_onchaind_missing_htlc_output(missing_htlc_msgs,
&htlcs[i]);
if (tell_immediately[i])
wire_sync_write(REQ_FD, take(msg));
@ -2545,7 +2545,7 @@ static void tell_wallet_to_remote(const struct tx_parts *tx,
per_commit_point = NULL;
wire_sync_write(REQ_FD,
take(towire_onchain_add_utxo(NULL, &tx->txid, outnum,
take(towire_onchaind_add_utxo(NULL, &tx->txid, outnum,
per_commit_point,
amt,
tx_blockheight,
@ -3307,7 +3307,7 @@ search_done:
if (!tell_if_missing[i])
continue;
msg = towire_onchain_missing_htlc_output(NULL, &htlcs[i]);
msg = towire_onchaind_missing_htlc_output(NULL, &htlcs[i]);
wire_sync_write(REQ_FD, take(msg));
}
@ -3345,7 +3345,7 @@ int main(int argc, char *argv[])
missing_htlc_msgs = tal_arr(ctx, u8 *, 0);
msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_onchain_init(tmpctx, msg,
if (!fromwire_onchaind_init(tmpctx, msg,
&shachain,
&chainparams,
&funding,
@ -3379,7 +3379,7 @@ int main(int argc, char *argv[])
&option_static_remotekey,
&option_anchor_outputs,
&open_is_replay)) {
master_badmsg(WIRE_ONCHAIN_INIT, msg);
master_badmsg(WIRE_ONCHAIND_INIT, msg);
}
status_debug("delayed_to_us_feerate = %u, htlc_feerate = %u, "
@ -3398,10 +3398,10 @@ int main(int argc, char *argv[])
for (u64 i = 0; i < num_htlcs; i++) {
msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_onchain_htlc(msg, &htlcs[i],
if (!fromwire_onchaind_htlc(msg, &htlcs[i],
&tell_if_missing[i],
&tell_immediately[i]))
master_badmsg(WIRE_ONCHAIN_HTLC, msg);
master_badmsg(WIRE_ONCHAIND_HTLC, msg);
}
outs = tal_arr(ctx, struct tracked_output *, 0);

2
onchaind/onchain_wire.c → onchaind/onchaind_wire.c

@ -1,5 +1,5 @@
#include <common/htlc_wire.h>
#include <onchaind/onchain_wire.h>
#include <onchaind/onchaind_wire.h>
#include <wire/wire.h>
void towire_htlc_stub(u8 **pptr, const struct htlc_stub *htlc_stub)

136
onchaind/onchaind_wire.csv

@ -0,0 +1,136 @@
#include <bitcoin/tx_parts.h>
#include <common/coin_mvt.h>
#include <common/derive_basepoints.h>
#include <common/htlc_wire.h>
#include <common/wallet.h>
# Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
msgtype,onchaind_init,5001
msgdata,onchaind_init,shachain,shachain,
# This needs to be set explicitly since the same message also contains a
# transaction that we need to parse correctly.
msgdata,onchaind_init,chainparams,chainparams,
msgdata,onchaind_init,funding_amount_satoshi,amount_sat,
# Our current balance (of funding amount, not counting any pending htlcs)
msgdata,onchaind_init,our_msat,amount_msat,
# Remote per commit point for committed tx.
msgdata,onchaind_init,old_remote_per_commitment_point,pubkey,
# Remote per commit point for current tx (needed if we haven't got revoke_and_ack yet).
msgdata,onchaind_init,remote_per_commitment_point,pubkey,
msgdata,onchaind_init,local_to_self_delay,u32,
msgdata,onchaind_init,remote_to_self_delay,u32,
msgdata,onchaind_init,delayed_to_us_feerate,u32,
msgdata,onchaind_init,htlc_feerate,u32,
msgdata,onchaind_init,penalty_feerate,u32,
msgdata,onchaind_init,local_dust_limit_satoshi,amount_sat,
# Gives an easy way to tell if it's our unilateral close or theirs...
msgdata,onchaind_init,our_broadcast_txid,bitcoin_txid,
msgdata,onchaind_init,local_scriptpubkey_len,u16,
msgdata,onchaind_init,local_scriptpubkey,u8,local_scriptpubkey_len
msgdata,onchaind_init,remote_scriptpubkey_len,u16,
msgdata,onchaind_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
msgdata,onchaind_init,ourwallet_pubkey,pubkey,
# We need these two for commit number obscurer
msgdata,onchaind_init,opener,enum side,
msgdata,onchaind_init,local_basepoints,basepoints,
msgdata,onchaind_init,remote_basepoints,basepoints,
msgdata,onchaind_init,tx_parts,tx_parts,
msgdata,onchaind_init,locktime,u32,
msgdata,onchaind_init,tx_blockheight,u32,
msgdata,onchaind_init,reasonable_depth,u32,
msgdata,onchaind_init,num_htlc_sigs,u16,
msgdata,onchaind_init,htlc_signature,bitcoin_signature,num_htlc_sigs
msgdata,onchaind_init,num_htlcs,u64,
msgdata,onchaind_init,min_possible_feerate,u32,
msgdata,onchaind_init,max_possible_feerate,u32,
msgdata,onchaind_init,possible_remote_per_commit_point,?pubkey,
msgdata,onchaind_init,local_funding_pubkey,pubkey,
msgdata,onchaind_init,remote_funding_pubkey,pubkey,
msgdata,onchaind_init,option_static_remotekey,bool,
msgdata,onchaind_init,option_anchor_outputs,bool,
msgdata,onchaind_init,is_replay,bool,
#include <onchaind/onchaind_wire.h>
# This is all the HTLCs: one per message
msgtype,onchaind_htlc,5002
msgdata,onchaind_htlc,htlc,htlc_stub,
# If it's not in the commitment tx, tell us (immediately or htlc_missing_depth)
msgdata,onchaind_htlc,tell_if_missing,bool,
msgdata,onchaind_htlc,tell_immediately,bool,
# This says we're ready; give us preimages.
msgtype,onchaind_init_reply,5101
# onchaind->master: Send out a tx.
msgtype,onchaind_broadcast_tx,5003
msgdata,onchaind_broadcast_tx,tx,bitcoin_tx,
msgdata,onchaind_broadcast_tx,type,enum wallet_tx_type,
# master->onchaind: Notifier that an output has been spent by input_num of tx.
msgtype,onchaind_spent,5004
msgdata,onchaind_spent,tx,tx_parts,
msgdata,onchaind_spent,input_num,u32,
msgdata,onchaind_spent,blockheight,u32,
msgdata,onchaind_spent,is_replay,bool,
# master->onchaind: We will receive more than one of these, as depth changes.
msgtype,onchaind_depth,5005
msgdata,onchaind_depth,txid,bitcoin_txid,
msgdata,onchaind_depth,depth,u32,
msgdata,onchaind_depth,is_replay,bool,
# onchaind->master: We don't want to watch this tx, or its outputs
msgtype,onchaind_unwatch_tx,5006
msgdata,onchaind_unwatch_tx,txid,bitcoin_txid,
# master->onchaind: We know HTLC preimage
msgtype,onchaind_known_preimage,5007
msgdata,onchaind_known_preimage,preimage,preimage,
msgdata,onchaind_known_preimage,is_replay,bool,
# onchaind->master: We discovered HTLC preimage
msgtype,onchaind_extracted_preimage,5008
msgdata,onchaind_extracted_preimage,preimage,preimage,
# onchaind->master: this HTLC was missing from commit tx.
msgtype,onchaind_missing_htlc_output,5009
msgdata,onchaind_missing_htlc_output,htlc,htlc_stub,
# onchaind->master: this HTLC has timed out (after reasonable_depth)
msgtype,onchaind_htlc_timeout,5010
msgdata,onchaind_htlc_timeout,htlc,htlc_stub,
# onchaind->master: this peer can be forgotten
msgtype,onchaind_all_irrevocably_resolved,5011
# onchaind->master: hey, I identified an UTXO you'll want to track
msgtype,onchaind_add_utxo,5012
msgdata,onchaind_add_utxo,prev_out_tx,bitcoin_txid,
msgdata,onchaind_add_utxo,prev_out_index,u32,
msgdata,onchaind_add_utxo,per_commit_point,?pubkey,
msgdata,onchaind_add_utxo,value,amount_sat,
msgdata,onchaind_add_utxo,blockheight,u32,
msgdata,onchaind_add_utxo,len,u16,
msgdata,onchaind_add_utxo,scriptpubkey,u8,len
# master -> onchaind: do you have a memleak?
msgtype,onchaind_dev_memleak,5033
msgtype,onchaind_dev_memleak_reply,5133
msgdata,onchaind_dev_memleak_reply,leak,bool,
# Tell the main daemon what we've been watching, mainly used for transactions
# that we tracked automatically but only onchaind knows how to classify their
# transactions.
msgtype,onchaind_annotate_txout,5035
msgdata,onchaind_annotate_txout,txid,bitcoin_txid,
msgdata,onchaind_annotate_txout,outnum,u32,
msgdata,onchaind_annotate_txout,type,enum wallet_tx_type,
msgtype,onchaind_annotate_txin,5036
msgdata,onchaind_annotate_txin,txid,bitcoin_txid,
msgdata,onchaind_annotate_txin,innum,u32,
msgdata,onchaind_annotate_txin,type,enum wallet_tx_type,
msgtype,onchaind_notify_coin_mvt,5037
msgdata,onchaind_notify_coin_mvt,mvt,chain_coin_mvt,
Can't render this file because it has a wrong number of fields in line 7.

6
onchaind/onchain_wire.h → onchaind/onchaind_wire.h

@ -1,5 +1,5 @@
#ifndef LIGHTNING_ONCHAIND_ONCHAIN_WIRE_H
#define LIGHTNING_ONCHAIND_ONCHAIN_WIRE_H
#ifndef LIGHTNING_ONCHAIND_ONCHAIND_WIRE_H
#define LIGHTNING_ONCHAIND_ONCHAIND_WIRE_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
@ -16,4 +16,4 @@ struct htlc_stub {
void towire_htlc_stub(u8 **pptr, const struct htlc_stub *htlc_stub);
void fromwire_htlc_stub(const u8 **cursor, size_t *max,
struct htlc_stub *htlc_stub);
#endif /* LIGHTNING_ONCHAIND_ONCHAIN_WIRE_H */
#endif /* LIGHTNING_ONCHAIND_ONCHAIND_WIRE_H */

114
onchaind/test/run-grind_feerate-bug.c

@ -40,24 +40,24 @@ void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_hsmd_get_per_commitment_point_reply */
bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *per_commitment_point UNNEEDED, struct secret **old_commitment_secret UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_get_per_commitment_point_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchain_depth */
bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_depth called!\n"); abort(); }
/* Generated stub for fromwire_onchain_dev_memleak */
bool fromwire_onchain_dev_memleak(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_dev_memleak called!\n"); abort(); }
/* Generated stub for fromwire_onchain_htlc */
bool fromwire_onchain_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_htlc called!\n"); abort(); }
/* Generated stub for fromwire_onchain_init */
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_init called!\n"); abort(); }
/* Generated stub for fromwire_onchain_known_preimage */
bool fromwire_onchain_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_known_preimage called!\n"); abort(); }
/* Generated stub for fromwire_onchain_spent */
bool fromwire_onchain_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_spent called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_depth */
bool fromwire_onchaind_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_depth called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_dev_memleak */
bool fromwire_onchaind_dev_memleak(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_dev_memleak called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_htlc */
bool fromwire_onchaind_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_htlc called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_init */
bool fromwire_onchaind_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_init called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_known_preimage */
bool fromwire_onchaind_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_known_preimage called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_spent */
bool fromwire_onchaind_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_spent called!\n"); abort(); }
/* Generated stub for fromwire_peektype */
int fromwire_peektype(const u8 *cursor UNNEEDED)
{ fprintf(stderr, "fromwire_peektype called!\n"); abort(); }
@ -189,9 +189,9 @@ struct chain_coin_mvt *new_coin_withdrawal_sat(const tal_t *ctx UNNEEDED,
/* Generated stub for notleak_ */
void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
/* Generated stub for onchain_wire_type_name */
const char *onchain_wire_type_name(int e UNNEEDED)
{ fprintf(stderr, "onchain_wire_type_name called!\n"); abort(); }
/* Generated stub for onchaind_wire_name */
const char *onchaind_wire_name(int e UNNEEDED)
{ fprintf(stderr, "onchaind_wire_name called!\n"); abort(); }
/* Generated stub for peer_billboard */
void peer_billboard(bool perm UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "peer_billboard called!\n"); abort(); }
@ -233,42 +233,42 @@ u8 *towire_hsmd_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secre
/* Generated stub for towire_hsmd_sign_remote_htlc_to_us */
u8 *towire_hsmd_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
{ fprintf(stderr, "towire_hsmd_sign_remote_htlc_to_us called!\n"); abort(); }
/* Generated stub for towire_onchain_add_utxo */
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
/* Generated stub for towire_onchain_all_irrevocably_resolved */
u8 *towire_onchain_all_irrevocably_resolved(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchain_all_irrevocably_resolved called!\n"); abort(); }
/* Generated stub for towire_onchain_annotate_txin */
u8 *towire_onchain_annotate_txin(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 innum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchain_annotate_txin called!\n"); abort(); }
/* Generated stub for towire_onchain_annotate_txout */
u8 *towire_onchain_annotate_txout(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 outnum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchain_annotate_txout called!\n"); abort(); }
/* Generated stub for towire_onchain_broadcast_tx */
u8 *towire_onchain_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchain_broadcast_tx called!\n"); abort(); }
/* Generated stub for towire_onchain_dev_memleak_reply */
u8 *towire_onchain_dev_memleak_reply(const tal_t *ctx UNNEEDED, bool leak UNNEEDED)
{ fprintf(stderr, "towire_onchain_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for towire_onchain_extracted_preimage */
u8 *towire_onchain_extracted_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "towire_onchain_extracted_preimage called!\n"); abort(); }
/* Generated stub for towire_onchain_htlc_timeout */
u8 *towire_onchain_htlc_timeout(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchain_htlc_timeout called!\n"); abort(); }
/* Generated stub for towire_onchain_init_reply */
u8 *towire_onchain_init_reply(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchain_init_reply called!\n"); abort(); }
/* Generated stub for towire_onchain_missing_htlc_output */
u8 *towire_onchain_missing_htlc_output(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchain_missing_htlc_output called!\n"); abort(); }
/* Generated stub for towire_onchain_notify_coin_mvt */
u8 *towire_onchain_notify_coin_mvt(const tal_t *ctx UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
{ fprintf(stderr, "towire_onchain_notify_coin_mvt called!\n"); abort(); }
/* Generated stub for towire_onchain_unwatch_tx */
u8 *towire_onchain_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED)
{ fprintf(stderr, "towire_onchain_unwatch_tx called!\n"); abort(); }
/* Generated stub for towire_onchaind_add_utxo */
u8 *towire_onchaind_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_onchaind_add_utxo called!\n"); abort(); }
/* Generated stub for towire_onchaind_all_irrevocably_resolved */
u8 *towire_onchaind_all_irrevocably_resolved(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_all_irrevocably_resolved called!\n"); abort(); }
/* Generated stub for towire_onchaind_annotate_txin */
u8 *towire_onchaind_annotate_txin(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 innum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_annotate_txin called!\n"); abort(); }
/* Generated stub for towire_onchaind_annotate_txout */
u8 *towire_onchaind_annotate_txout(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 outnum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_annotate_txout called!\n"); abort(); }
/* Generated stub for towire_onchaind_broadcast_tx */
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_broadcast_tx called!\n"); abort(); }
/* Generated stub for towire_onchaind_dev_memleak_reply */
u8 *towire_onchaind_dev_memleak_reply(const tal_t *ctx UNNEEDED, bool leak UNNEEDED)
{ fprintf(stderr, "towire_onchaind_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for towire_onchaind_extracted_preimage */
u8 *towire_onchaind_extracted_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "towire_onchaind_extracted_preimage called!\n"); abort(); }
/* Generated stub for towire_onchaind_htlc_timeout */
u8 *towire_onchaind_htlc_timeout(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchaind_htlc_timeout called!\n"); abort(); }
/* Generated stub for towire_onchaind_init_reply */
u8 *towire_onchaind_init_reply(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_init_reply called!\n"); abort(); }
/* Generated stub for towire_onchaind_missing_htlc_output */
u8 *towire_onchaind_missing_htlc_output(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchaind_missing_htlc_output called!\n"); abort(); }
/* Generated stub for towire_onchaind_notify_coin_mvt */
u8 *towire_onchaind_notify_coin_mvt(const tal_t *ctx UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
{ fprintf(stderr, "towire_onchaind_notify_coin_mvt called!\n"); abort(); }
/* Generated stub for towire_onchaind_unwatch_tx */
u8 *towire_onchaind_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED)
{ fprintf(stderr, "towire_onchaind_unwatch_tx called!\n"); abort(); }
/* Generated stub for towire_secp256k1_ecdsa_signature */
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
const secp256k1_ecdsa_signature *signature UNNEEDED)

108
onchaind/test/run-grind_feerate.c

@ -44,24 +44,24 @@ bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, con
/* Generated stub for fromwire_hsmd_sign_tx_reply */
bool fromwire_hsmd_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchain_depth */
bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_depth called!\n"); abort(); }
/* Generated stub for fromwire_onchain_dev_memleak */
bool fromwire_onchain_dev_memleak(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_dev_memleak called!\n"); abort(); }
/* Generated stub for fromwire_onchain_htlc */
bool fromwire_onchain_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_htlc called!\n"); abort(); }
/* Generated stub for fromwire_onchain_init */
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_init called!\n"); abort(); }
/* Generated stub for fromwire_onchain_known_preimage */
bool fromwire_onchain_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_known_preimage called!\n"); abort(); }
/* Generated stub for fromwire_onchain_spent */
bool fromwire_onchain_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_spent called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_depth */
bool fromwire_onchaind_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_depth called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_dev_memleak */
bool fromwire_onchaind_dev_memleak(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_dev_memleak called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_htlc */
bool fromwire_onchaind_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_htlc called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_init */
bool fromwire_onchaind_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, bool *option_static_remotekey UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_init called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_known_preimage */
bool fromwire_onchaind_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_known_preimage called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_spent */
bool fromwire_onchaind_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED, bool *is_replay UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_spent called!\n"); abort(); }
/* Generated stub for fromwire_secp256k1_ecdsa_signature */
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
secp256k1_ecdsa_signature *signature UNNEEDED)
@ -253,42 +253,42 @@ u8 *towire_hsmd_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secre
/* Generated stub for towire_hsmd_sign_remote_htlc_to_us */
u8 *towire_hsmd_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
{ fprintf(stderr, "towire_hsmd_sign_remote_htlc_to_us called!\n"); abort(); }
/* Generated stub for towire_onchain_add_utxo */
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
/* Generated stub for towire_onchain_all_irrevocably_resolved */
u8 *towire_onchain_all_irrevocably_resolved(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchain_all_irrevocably_resolved called!\n"); abort(); }
/* Generated stub for towire_onchain_annotate_txin */
u8 *towire_onchain_annotate_txin(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 innum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchain_annotate_txin called!\n"); abort(); }
/* Generated stub for towire_onchain_annotate_txout */
u8 *towire_onchain_annotate_txout(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 outnum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchain_annotate_txout called!\n"); abort(); }
/* Generated stub for towire_onchain_broadcast_tx */
u8 *towire_onchain_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchain_broadcast_tx called!\n"); abort(); }
/* Generated stub for towire_onchain_dev_memleak_reply */
u8 *towire_onchain_dev_memleak_reply(const tal_t *ctx UNNEEDED, bool leak UNNEEDED)
{ fprintf(stderr, "towire_onchain_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for towire_onchain_extracted_preimage */
u8 *towire_onchain_extracted_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "towire_onchain_extracted_preimage called!\n"); abort(); }
/* Generated stub for towire_onchain_htlc_timeout */
u8 *towire_onchain_htlc_timeout(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchain_htlc_timeout called!\n"); abort(); }
/* Generated stub for towire_onchain_init_reply */
u8 *towire_onchain_init_reply(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchain_init_reply called!\n"); abort(); }
/* Generated stub for towire_onchain_missing_htlc_output */
u8 *towire_onchain_missing_htlc_output(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchain_missing_htlc_output called!\n"); abort(); }
/* Generated stub for towire_onchain_notify_coin_mvt */
u8 *towire_onchain_notify_coin_mvt(const tal_t *ctx UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
{ fprintf(stderr, "towire_onchain_notify_coin_mvt called!\n"); abort(); }
/* Generated stub for towire_onchain_unwatch_tx */
u8 *towire_onchain_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED)
{ fprintf(stderr, "towire_onchain_unwatch_tx called!\n"); abort(); }
/* Generated stub for towire_onchaind_add_utxo */
u8 *towire_onchaind_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_onchaind_add_utxo called!\n"); abort(); }
/* Generated stub for towire_onchaind_all_irrevocably_resolved */
u8 *towire_onchaind_all_irrevocably_resolved(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_all_irrevocably_resolved called!\n"); abort(); }
/* Generated stub for towire_onchaind_annotate_txin */
u8 *towire_onchaind_annotate_txin(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 innum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_annotate_txin called!\n"); abort(); }
/* Generated stub for towire_onchaind_annotate_txout */
u8 *towire_onchaind_annotate_txout(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, u32 outnum UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_annotate_txout called!\n"); abort(); }
/* Generated stub for towire_onchaind_broadcast_tx */
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_broadcast_tx called!\n"); abort(); }
/* Generated stub for towire_onchaind_dev_memleak_reply */
u8 *towire_onchaind_dev_memleak_reply(const tal_t *ctx UNNEEDED, bool leak UNNEEDED)
{ fprintf(stderr, "towire_onchaind_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for towire_onchaind_extracted_preimage */
u8 *towire_onchaind_extracted_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "towire_onchaind_extracted_preimage called!\n"); abort(); }
/* Generated stub for towire_onchaind_htlc_timeout */
u8 *towire_onchaind_htlc_timeout(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchaind_htlc_timeout called!\n"); abort(); }
/* Generated stub for towire_onchaind_init_reply */
u8 *towire_onchaind_init_reply(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_init_reply called!\n"); abort(); }
/* Generated stub for towire_onchaind_missing_htlc_output */
u8 *towire_onchaind_missing_htlc_output(const tal_t *ctx UNNEEDED, const struct htlc_stub *htlc UNNEEDED)
{ fprintf(stderr, "towire_onchaind_missing_htlc_output called!\n"); abort(); }
/* Generated stub for towire_onchaind_notify_coin_mvt */
u8 *towire_onchaind_notify_coin_mvt(const tal_t *ctx UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
{ fprintf(stderr, "towire_onchaind_notify_coin_mvt called!\n"); abort(); }
/* Generated stub for towire_onchaind_unwatch_tx */
u8 *towire_onchaind_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *txid UNNEEDED)
{ fprintf(stderr, "towire_onchaind_unwatch_tx called!\n"); abort(); }
/* Generated stub for towire_secp256k1_ecdsa_signature */
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
const secp256k1_ecdsa_signature *signature UNNEEDED)

18
wallet/test/run-wallet.c

@ -141,9 +141,9 @@ bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, cons
/* Generated stub for fromwire_hsmd_sign_commitment_tx_reply */
bool fromwire_hsmd_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_commitment_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchain_dev_memleak_reply */
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_dev_memleak_reply */
bool fromwire_onchaind_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for get_block_height */
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
{ fprintf(stderr, "get_block_height called!\n"); abort(); }
@ -714,12 +714,12 @@ u8 *towire_invalid_onion_payload(const tal_t *ctx UNNEEDED, bigsize type UNNEEDE
/* Generated stub for towire_invalid_realm */
u8 *towire_invalid_realm(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_invalid_realm called!\n"); abort(); }
/* Generated stub for towire_onchain_dev_memleak */
u8 *towire_onchain_dev_memleak(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchain_dev_memleak called!\n"); abort(); }
/* Generated stub for towire_onchain_known_preimage */
u8 *towire_onchain_known_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED, bool is_replay UNNEEDED)
{ fprintf(stderr, "towire_onchain_known_preimage called!\n"); abort(); }
/* Generated stub for towire_onchaind_dev_memleak */
u8 *towire_onchaind_dev_memleak(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_dev_memleak called!\n"); abort(); }
/* Generated stub for towire_onchaind_known_preimage */
u8 *towire_onchaind_known_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED, bool is_replay UNNEEDED)
{ fprintf(stderr, "towire_onchaind_known_preimage called!\n"); abort(); }
/* Generated stub for towire_permanent_channel_failure */
u8 *towire_permanent_channel_failure(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_permanent_channel_failure called!\n"); abort(); }

4
wallet/wallet.c

@ -17,7 +17,7 @@
#include <lightningd/notification.h>
#include <lightningd/peer_control.h>
#include <lightningd/peer_htlcs.h>
#include <onchaind/gen_onchain_wire.h>
#include <onchaind/onchaind_wiregen.h>
#include <string.h>
#include <wallet/db_common.h>
@ -3670,7 +3670,7 @@ u32 *wallet_onchaind_channels(struct wallet *w,
stmt = db_prepare_v2(
w->db,
SQL("SELECT DISTINCT(channel_id) FROM channeltxs WHERE type = ?;"));
db_bind_int(stmt, 0, WIRE_ONCHAIN_INIT);
db_bind_int(stmt, 0, WIRE_ONCHAIND_INIT);
db_query_prepared(stmt);
while (db_step(stmt)) {

2
wallet/wallet.h

@ -18,7 +18,7 @@
#include <lightningd/htlc_end.h>
#include <lightningd/invoice.h>
#include <lightningd/log.h>
#include <onchaind/onchain_wire.h>
#include <onchaind/onchaind_wire.h>
#include <wally_bip32.h>
#include <wire/gen_onion_wire.h>

Loading…
Cancel
Save