2021-12-04 21:53:56 +10:30
|
|
|
#include "config.h"
|
2017-11-01 11:40:48 +10:30
|
|
|
#include <lightningd/log.h>
|
|
|
|
|
|
2017-12-12 14:12:37 +10:30
|
|
|
#include "test_utils.h"
|
2022-03-01 11:22:15 -06:00
|
|
|
#include <ccan/tal/str/str.h>
|
2022-01-03 12:45:35 -06:00
|
|
|
#include <db/common.h>
|
2017-11-01 11:40:48 +10:30
|
|
|
|
2023-07-16 15:26:52 +09:30
|
|
|
static void db_log_(struct logger *log UNUSED, enum log_level level UNUSED, const struct node_id *node_id UNUSED, bool call_notifier UNUSED, const char *fmt UNUSED, ...)
|
2018-01-02 14:33:42 +10:30
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#define log_ db_log_
|
|
|
|
|
|
2022-03-01 11:22:15 -06:00
|
|
|
static char *wallet_err;
|
|
|
|
|
|
2023-06-30 04:53:08 +09:30
|
|
|
static void test_error(struct lightningd *ld, bool fatal, const char *fmt, va_list ap)
|
|
|
|
|
{
|
2022-03-01 11:22:15 -06:00
|
|
|
/* Fail hard if we're complaining about not being in transaction */
|
|
|
|
|
assert(!strstarts(fmt, "No longer in transaction"));
|
|
|
|
|
|
|
|
|
|
wallet_err = tal_vfmt(NULL, fmt, ap);
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-21 00:30:52 +05:30
|
|
|
#include "common/scb_wiregen.c"
|
2017-12-12 14:12:37 +10:30
|
|
|
#include "wallet/wallet.c"
|
2023-03-21 14:28:15 +10:30
|
|
|
#include "lightningd/hsm_control.c"
|
2018-02-05 14:39:27 +10:30
|
|
|
#include "lightningd/htlc_end.c"
|
2018-02-12 20:42:55 +10:30
|
|
|
#include "lightningd/peer_control.c"
|
2018-09-03 10:38:53 +09:30
|
|
|
#include "lightningd/peer_htlcs.c"
|
2018-02-12 20:42:55 +10:30
|
|
|
#include "lightningd/channel.c"
|
2024-01-31 13:46:17 +10:30
|
|
|
#include "lightningd/channel_gossip.c"
|
2023-10-28 11:08:09 +10:30
|
|
|
#include "lightningd/pay.c"
|
|
|
|
|
#include "lightningd/wait.c"
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2022-01-03 12:45:35 -06:00
|
|
|
#include "db/bindings.c"
|
|
|
|
|
#include "db/db_sqlite3.c"
|
|
|
|
|
#include "db/exec.c"
|
|
|
|
|
#include "db/utils.c"
|
2017-12-12 14:12:37 +10:30
|
|
|
#include "wallet/db.c"
|
2025-11-27 15:15:36 +10:30
|
|
|
#include "wallet/migrations.c"
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2020-05-15 17:13:22 -05:00
|
|
|
#include <common/setup.h>
|
2021-12-05 02:47:38 -05:00
|
|
|
#include <common/utils.h>
|
2017-05-31 15:26:30 +02:00
|
|
|
#include <stdio.h>
|
2025-10-22 19:44:27 +10:30
|
|
|
#include <wally_script.h>
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2017-12-12 14:12:38 +10:30
|
|
|
/* AUTOGENERATED MOCKS START */
|
2024-01-31 13:46:18 +10:30
|
|
|
/* Generated stub for add_node_announcement_sig */
|
|
|
|
|
void add_node_announcement_sig(u8 *nannounce UNNEEDED,
|
|
|
|
|
const secp256k1_ecdsa_signature *sig UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "add_node_announcement_sig called!\n"); abort(); }
|
2025-03-31 16:53:26 +10:30
|
|
|
/* Generated stub for bitcoind_getrawblockbyheight_ */
|
|
|
|
|
void bitcoind_getrawblockbyheight_(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct bitcoind *bitcoind UNNEEDED,
|
|
|
|
|
u32 height UNNEEDED,
|
|
|
|
|
void (*cb)(struct bitcoind *bitcoind_ UNNEEDED,
|
|
|
|
|
u32 height_ UNNEEDED,
|
|
|
|
|
struct bitcoin_blkid *blkid UNNEEDED,
|
|
|
|
|
struct bitcoin_block *blk UNNEEDED,
|
|
|
|
|
void *arg) UNNEEDED,
|
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "bitcoind_getrawblockbyheight_ called!\n"); abort(); }
|
2020-01-09 16:38:12 +01:00
|
|
|
/* Generated stub for bitcoind_getutxout_ */
|
2024-06-23 00:41:33 +09:30
|
|
|
void bitcoind_getutxout_(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct bitcoind *bitcoind UNNEEDED,
|
2021-10-13 14:15:36 +10:30
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED,
|
2022-07-25 16:31:09 +09:30
|
|
|
void (*cb)(struct bitcoind * UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx_output * UNNEEDED,
|
|
|
|
|
void *) UNNEEDED,
|
2020-01-09 16:38:12 +01:00
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "bitcoind_getutxout_ called!\n"); abort(); }
|
2025-11-18 14:38:04 +10:30
|
|
|
/* Generated stub for bitcoind_sendrawtx_ */
|
|
|
|
|
void bitcoind_sendrawtx_(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct bitcoind *bitcoind UNNEEDED,
|
|
|
|
|
const char *id_prefix TAKES UNNEEDED,
|
|
|
|
|
const char *hextx UNNEEDED,
|
|
|
|
|
bool allowhighfees UNNEEDED,
|
|
|
|
|
void (*cb)(struct bitcoind * UNNEEDED,
|
|
|
|
|
bool success UNNEEDED, const char *msg UNNEEDED, void *) UNNEEDED,
|
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "bitcoind_sendrawtx_ called!\n"); abort(); }
|
2023-03-23 16:15:52 +10:30
|
|
|
/* Generated stub for broadcast_tx_ */
|
2023-10-24 12:11:30 +10:30
|
|
|
void broadcast_tx_(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
2023-03-23 16:15:52 +10:30
|
|
|
struct channel *channel UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx *tx TAKES UNNEEDED,
|
chaintopology: allow minblock for broadcast_tx.
Fun story. We're changing onchaind to hand txs to us, and we will
construct them and do the broadcast for it. lightningd tells onchaind
the witness it used (with flags to indicate which fields were
signatures so should be ignored) so onchaind can recognize the tx
when/if it is mined.
And when onchaind was waiting for a CLTV delay, it wouldn't tell
lightningd yet, but wait until the parent was sufficiently deep
But this caused bugs!
In particular, on replay, onchaind would see transactions which it
hasn't sent yet. This was not a problem before, as onchaind had
created the tx, even if it hadn't told lightningd to broadcast it, so
recognized the variant when it came in. When we're relying on
lightningd to tell us what the tx will look like, this doesn't work
any more.
The cause of this is that we fire off txowatches ("this output was
spent!") while we process blocks, and only fire off txwatches ("this
tx increased depth") once all the current blocks are processed. Often
this didn't matter, since we replay messages to onchaind from the
database, *but* we trim the last few blocks on restart (or, if there's
a small reorg while we're stopped), and we can hit this misordering.
Changing our topology code to only ever process one block at a time
would be a solution, but slows down catchup (and tests, where we often
mine a run of blocks).
So, this seems like a premature optimization, but it's really
required! And in future, lightningd can use this knowledge of pending
transactions to combine them in more clever ways.
Note that if a tx is valid at block N, we broadcast it once we see
block N-1, to get it in the mempool for block N.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-23 16:17:52 +10:30
|
|
|
const char *cmd_id UNNEEDED, bool allowhighfees UNNEEDED, u32 minblock UNNEEDED,
|
2023-06-26 08:36:21 +09:30
|
|
|
bool (*finished)(struct channel * UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx * UNNEEDED,
|
2023-03-23 16:15:52 +10:30
|
|
|
bool success UNNEEDED,
|
2023-06-26 08:36:21 +09:30
|
|
|
const char *err UNNEEDED,
|
|
|
|
|
void *) UNNEEDED,
|
2023-03-23 16:15:52 +10:30
|
|
|
bool (*refresh)(struct channel * UNNEEDED, const struct bitcoin_tx ** UNNEEDED, void *) UNNEEDED,
|
2023-06-26 08:36:21 +09:30
|
|
|
void *cbarg TAKES UNNEEDED)
|
2023-03-23 16:15:52 +10:30
|
|
|
{ fprintf(stderr, "broadcast_tx_ called!\n"); abort(); }
|
2025-08-19 10:30:46 +09:30
|
|
|
/* Generated stub for chain_mvt_index_created */
|
|
|
|
|
u64 chain_mvt_index_created(struct lightningd *ld UNNEEDED,
|
2025-08-19 10:30:52 +09:30
|
|
|
struct db *db UNNEEDED,
|
2025-08-19 10:30:46 +09:30
|
|
|
const struct mvt_account_id *account UNNEEDED,
|
|
|
|
|
struct amount_msat credit UNNEEDED,
|
|
|
|
|
struct amount_msat debit UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "chain_mvt_index_created called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for channel_mvt_index_created */
|
|
|
|
|
u64 channel_mvt_index_created(struct lightningd *ld UNNEEDED,
|
2025-08-19 10:30:52 +09:30
|
|
|
struct db *db UNNEEDED,
|
2025-08-19 10:30:46 +09:30
|
|
|
const struct mvt_account_id *account UNNEEDED,
|
|
|
|
|
struct amount_msat credit UNNEEDED,
|
|
|
|
|
struct amount_msat debit UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channel_mvt_index_created called!\n"); abort(); }
|
2021-05-11 11:58:00 -05:00
|
|
|
/* Generated stub for channel_unsaved_close_conn */
|
|
|
|
|
void channel_unsaved_close_conn(struct channel *channel UNNEEDED, const char *why UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channel_unsaved_close_conn called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for channel_update_details */
|
|
|
|
|
bool channel_update_details(const u8 *channel_update UNNEEDED,
|
|
|
|
|
u32 *timestamp UNNEEDED,
|
|
|
|
|
bool *enabled UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channel_update_details called!\n"); abort(); }
|
2023-07-21 16:49:22 +09:30
|
|
|
/* Generated stub for channel_update_feerates */
|
|
|
|
|
void channel_update_feerates(struct lightningd *ld UNNEEDED, const struct channel *channel UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channel_update_feerates called!\n"); abort(); }
|
2021-05-20 16:50:42 -05:00
|
|
|
/* Generated stub for channel_update_reserve */
|
|
|
|
|
void channel_update_reserve(struct channel *channel UNNEEDED,
|
|
|
|
|
struct channel_config *their_config UNNEEDED,
|
|
|
|
|
struct amount_sat funding_total UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channel_update_reserve called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for channel_update_same */
|
|
|
|
|
bool channel_update_same(const u8 *cupdate1 UNNEEDED, const u8 *cupdate2 UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channel_update_same called!\n"); abort(); }
|
2023-10-02 09:29:49 +10:30
|
|
|
/* Generated stub for channeld_tell_depth */
|
|
|
|
|
void channeld_tell_depth(struct channel *channel UNNEEDED,
|
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
|
u32 depth UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "channeld_tell_depth called!\n"); abort(); }
|
2024-01-31 13:46:18 +10:30
|
|
|
/* Generated stub for check_announce_sigs */
|
|
|
|
|
const char *check_announce_sigs(const struct channel *channel UNNEEDED,
|
|
|
|
|
struct short_channel_id scid UNNEEDED,
|
|
|
|
|
const secp256k1_ecdsa_signature *remote_node_signature UNNEEDED,
|
|
|
|
|
const secp256k1_ecdsa_signature *remote_bitcoin_signature UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "check_announce_sigs called!\n"); abort(); }
|
2023-07-31 21:03:22 +09:30
|
|
|
/* Generated stub for cmd_id_from_close_command */
|
|
|
|
|
const char *cmd_id_from_close_command(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct lightningd *ld UNNEEDED, struct channel *channel UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "cmd_id_from_close_command called!\n"); abort(); }
|
2023-10-25 07:39:04 +10:30
|
|
|
/* Generated stub for command_check_done */
|
|
|
|
|
struct command_result *command_check_done(struct command *cmd)
|
|
|
|
|
|
|
|
|
|
{ fprintf(stderr, "command_check_done called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for command_check_only */
|
|
|
|
|
bool command_check_only(const struct command *cmd UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_check_only called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for command_deprecated_in_ok */
|
|
|
|
|
bool command_deprecated_in_ok(struct command *cmd UNNEEDED,
|
|
|
|
|
const char *param UNNEEDED,
|
|
|
|
|
const char *depr_start UNNEEDED,
|
|
|
|
|
const char *depr_end UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_deprecated_in_ok called!\n"); abort(); }
|
2024-06-19 10:06:35 +09:30
|
|
|
/* Generated stub for command_deprecated_out_ok */
|
|
|
|
|
bool command_deprecated_out_ok(struct command *cmd UNNEEDED,
|
|
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
|
const char *depr_start UNNEEDED,
|
|
|
|
|
const char *depr_end UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_deprecated_out_ok called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for command_dev_apis */
|
|
|
|
|
bool command_dev_apis(const struct command *cmd UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_dev_apis called!\n"); abort(); }
|
2018-02-12 20:42:55 +10:30
|
|
|
/* Generated stub for command_fail */
|
2022-09-18 09:50:50 +09:30
|
|
|
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
|
2018-12-16 15:19:06 +10:30
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
{ fprintf(stderr, "command_fail called!\n"); abort(); }
|
2023-10-28 11:08:09 +10:30
|
|
|
/* Generated stub for command_failed */
|
|
|
|
|
struct command_result *command_failed(struct command *cmd UNNEEDED,
|
|
|
|
|
struct json_stream *result)
|
|
|
|
|
|
|
|
|
|
{ fprintf(stderr, "command_failed called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for command_filter_ptr */
|
|
|
|
|
struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_filter_ptr called!\n"); abort(); }
|
2024-10-22 13:29:47 +10:30
|
|
|
/* Generated stub for command_its_complicated */
|
|
|
|
|
struct command_result *command_its_complicated(const char *why UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_its_complicated called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for command_log */
|
|
|
|
|
void command_log(struct command *cmd UNNEEDED, enum log_level level UNNEEDED,
|
|
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
|
|
|
|
|
|
{ fprintf(stderr, "command_log called!\n"); abort(); }
|
2018-12-16 15:22:06 +10:30
|
|
|
/* Generated stub for command_param_failed */
|
|
|
|
|
struct command_result *command_param_failed(void)
|
2018-12-17 14:22:08 +10:30
|
|
|
|
2018-12-16 15:22:06 +10:30
|
|
|
{ fprintf(stderr, "command_param_failed called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for command_set_usage */
|
|
|
|
|
void command_set_usage(struct command *cmd UNNEEDED, const char *usage UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_set_usage called!\n"); abort(); }
|
2018-02-12 20:42:55 +10:30
|
|
|
/* Generated stub for command_still_pending */
|
2018-12-17 14:22:08 +10:30
|
|
|
struct command_result *command_still_pending(struct command *cmd)
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
{ fprintf(stderr, "command_still_pending called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for command_success */
|
2018-12-16 15:19:06 +10:30
|
|
|
struct command_result *command_success(struct command *cmd UNNEEDED,
|
2018-12-17 14:22:08 +10:30
|
|
|
struct json_stream *response)
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
{ fprintf(stderr, "command_success called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for command_usage_only */
|
|
|
|
|
bool command_usage_only(const struct command *cmd UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "command_usage_only called!\n"); abort(); }
|
2023-06-26 08:38:21 +09:30
|
|
|
/* Generated stub for commit_tx_boost */
|
2023-10-26 13:07:10 +10:30
|
|
|
void commit_tx_boost(struct channel *channel UNNEEDED,
|
|
|
|
|
struct anchor_details *adet UNNEEDED,
|
|
|
|
|
bool success UNNEEDED)
|
2023-06-26 08:38:21 +09:30
|
|
|
{ fprintf(stderr, "commit_tx_boost called!\n"); abort(); }
|
2022-09-13 06:49:12 +09:30
|
|
|
/* Generated stub for connect_any_cmd_id */
|
|
|
|
|
const char *connect_any_cmd_id(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct lightningd *ld UNNEEDED, const struct peer *peer UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "connect_any_cmd_id called!\n"); abort(); }
|
2022-07-16 14:19:31 +09:30
|
|
|
/* Generated stub for connect_failed_disconnect */
|
2022-07-18 21:42:28 +09:30
|
|
|
void connect_failed_disconnect(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct node_id *id UNNEEDED,
|
|
|
|
|
const struct wireaddr_internal *addr UNNEEDED)
|
2022-07-16 14:19:31 +09:30
|
|
|
{ fprintf(stderr, "connect_failed_disconnect called!\n"); abort(); }
|
2018-08-09 09:55:29 +09:30
|
|
|
/* Generated stub for connect_succeeded */
|
2021-03-16 14:14:36 +10:30
|
|
|
void connect_succeeded(struct lightningd *ld UNNEEDED, const struct peer *peer UNNEEDED,
|
2021-03-25 14:23:31 +10:30
|
|
|
bool incoming UNNEEDED,
|
2021-03-16 14:14:36 +10:30
|
|
|
const struct wireaddr_internal *addr UNNEEDED)
|
2018-08-09 09:55:29 +09:30
|
|
|
{ fprintf(stderr, "connect_succeeded called!\n"); abort(); }
|
2024-11-25 11:38:15 +10:30
|
|
|
/* Generated stub for connectd_connect_to_peer */
|
|
|
|
|
void connectd_connect_to_peer(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct peer *peer UNNEEDED,
|
2025-11-11 11:33:17 +10:30
|
|
|
const char *reason UNNEEDED,
|
2024-11-25 11:38:15 +10:30
|
|
|
bool is_important UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "connectd_connect_to_peer called!\n"); abort(); }
|
2023-06-26 08:38:21 +09:30
|
|
|
/* Generated stub for create_anchor_details */
|
|
|
|
|
struct anchor_details *create_anchor_details(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct channel *channel UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx *tx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "create_anchor_details called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for create_channel_announcement */
|
|
|
|
|
u8 *create_channel_announcement(const tal_t *ctx UNNEEDED,
|
|
|
|
|
const struct channel *channel UNNEEDED,
|
2024-01-31 13:46:18 +10:30
|
|
|
struct short_channel_id scid UNNEEDED,
|
2024-01-31 13:46:17 +10:30
|
|
|
const secp256k1_ecdsa_signature *local_node_signature UNNEEDED,
|
|
|
|
|
const secp256k1_ecdsa_signature *local_bitcoin_signature UNNEEDED,
|
|
|
|
|
const secp256k1_ecdsa_signature *remote_node_signature UNNEEDED,
|
|
|
|
|
const secp256k1_ecdsa_signature *remote_bitcoin_signature UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "create_channel_announcement called!\n"); abort(); }
|
2023-10-02 09:29:51 +10:30
|
|
|
/* Generated stub for depthcb_update_scid */
|
|
|
|
|
bool depthcb_update_scid(struct channel *channel UNNEEDED,
|
2023-10-02 09:29:52 +10:30
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
2023-10-02 09:29:51 +10:30
|
|
|
{ fprintf(stderr, "depthcb_update_scid called!\n"); abort(); }
|
2023-09-21 15:06:28 +09:30
|
|
|
/* Generated stub for dev_disconnect_permanent */
|
|
|
|
|
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "dev_disconnect_permanent called!\n"); abort(); }
|
2018-08-09 11:57:20 +09:30
|
|
|
/* Generated stub for fatal */
|
|
|
|
|
void fatal(const char *fmt UNNEEDED, ...)
|
|
|
|
|
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
2023-06-30 04:53:08 +09:30
|
|
|
/* Generated stub for fatal_vfmt */
|
|
|
|
|
void fatal_vfmt(const char *fmt UNNEEDED, va_list ap UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fatal_vfmt called!\n"); abort(); }
|
2025-10-23 10:08:43 +10:30
|
|
|
/* Generated stub for find_txwatch_ */
|
|
|
|
|
struct txwatch *find_txwatch_(struct chain_topology *topo UNNEEDED,
|
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
|
enum watch_result (*cb)(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct bitcoin_txid * UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx * UNNEEDED,
|
|
|
|
|
unsigned int depth UNNEEDED,
|
|
|
|
|
void *arg) UNNEEDED,
|
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "find_txwatch_ called!\n"); abort(); }
|
2023-10-22 14:37:31 +10:30
|
|
|
/* Generated stub for force_peer_disconnect */
|
|
|
|
|
void force_peer_disconnect(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct peer *peer UNNEEDED,
|
|
|
|
|
const char *why UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "force_peer_disconnect called!\n"); abort(); }
|
2023-10-28 13:41:11 +10:30
|
|
|
/* Generated stub for forward_index_created */
|
|
|
|
|
u64 forward_index_created(struct lightningd *ld UNNEEDED,
|
|
|
|
|
enum forward_status status UNNEEDED,
|
|
|
|
|
struct short_channel_id in_channel UNNEEDED,
|
2023-10-28 13:42:18 +10:30
|
|
|
u64 in_htlc_id UNNEEDED,
|
2023-10-28 13:41:11 +10:30
|
|
|
struct amount_msat in_amount UNNEEDED,
|
|
|
|
|
const struct short_channel_id *out_channel UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "forward_index_created called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for forward_index_deleted */
|
|
|
|
|
void forward_index_deleted(struct lightningd *ld UNNEEDED,
|
|
|
|
|
enum forward_status status UNNEEDED,
|
|
|
|
|
struct short_channel_id in_channel UNNEEDED,
|
2023-10-28 13:42:18 +10:30
|
|
|
u64 in_htlc_id UNNEEDED,
|
2023-10-28 13:41:11 +10:30
|
|
|
const struct amount_msat *in_amount UNNEEDED,
|
|
|
|
|
const struct short_channel_id *out_channel UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "forward_index_deleted called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for forward_index_update_status */
|
|
|
|
|
u64 forward_index_update_status(struct lightningd *ld UNNEEDED,
|
|
|
|
|
enum forward_status status UNNEEDED,
|
|
|
|
|
struct short_channel_id in_channel UNNEEDED,
|
2023-10-28 13:42:18 +10:30
|
|
|
u64 in_htlc_id UNNEEDED,
|
2023-10-28 13:41:11 +10:30
|
|
|
struct amount_msat in_amount UNNEEDED,
|
|
|
|
|
const struct short_channel_id *out_channel UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "forward_index_update_status called!\n"); abort(); }
|
2020-08-25 11:03:16 +09:30
|
|
|
/* Generated stub for fromwire_channeld_dev_memleak_reply */
|
|
|
|
|
bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for fromwire_channeld_got_commitsig */
|
2025-08-26 15:22:01 +01:00
|
|
|
bool fromwire_channeld_got_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct bitcoin_signature *signature UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, struct added_htlc ***added UNNEEDED, struct fulfilled_htlc **fulfilled UNNEEDED, struct failed_htlc ***failed UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_tx **tx UNNEEDED, struct commitsig ***inflight_commitsigs UNNEEDED)
|
2020-08-25 11:03:16 +09:30
|
|
|
{ fprintf(stderr, "fromwire_channeld_got_commitsig called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for fromwire_channeld_got_revoke */
|
2021-06-22 16:47:33 -05:00
|
|
|
bool fromwire_channeld_got_revoke(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *revokenum UNNEEDED, struct secret *per_commitment_secret UNNEEDED, struct pubkey *next_per_commit_point UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct penalty_base **pbase UNNEEDED, struct bitcoin_tx **penalty_tx UNNEEDED)
|
2020-08-25 11:03:16 +09:30
|
|
|
{ fprintf(stderr, "fromwire_channeld_got_revoke called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for fromwire_channeld_offer_htlc_reply */
|
|
|
|
|
bool fromwire_channeld_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u8 **failuremsg UNNEEDED, wirestring **failurestr UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_channeld_offer_htlc_reply called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for fromwire_channeld_sending_commitsig */
|
2023-10-26 13:01:55 +10:30
|
|
|
bool fromwire_channeld_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct penalty_base **pbase UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct changed_htlc **changed UNNEEDED)
|
2020-08-25 11:03:16 +09:30
|
|
|
{ fprintf(stderr, "fromwire_channeld_sending_commitsig called!\n"); abort(); }
|
2020-08-25 11:46:22 +09:30
|
|
|
/* Generated stub for fromwire_connectd_peer_connected */
|
2025-11-11 11:33:17 +10:30
|
|
|
bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, u64 *counter UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct wireaddr **remote_addr UNNEEDED, bool *incoming UNNEEDED, u8 **features UNNEEDED, wirestring **connect_reason UNNEEDED, u64 *connect_nsec UNNEEDED)
|
2020-08-25 11:46:22 +09:30
|
|
|
{ fprintf(stderr, "fromwire_connectd_peer_connected called!\n"); abort(); }
|
2025-09-30 13:38:09 +09:30
|
|
|
/* Generated stub for fromwire_connectd_peer_disconnected */
|
2025-11-11 16:12:15 +10:30
|
|
|
bool fromwire_connectd_peer_disconnected(const void *p UNNEEDED, struct node_id *id UNNEEDED, u64 *counter UNNEEDED, u64 *connected_time_nsec UNNEEDED)
|
2025-09-30 13:38:09 +09:30
|
|
|
{ fprintf(stderr, "fromwire_connectd_peer_disconnected called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for fromwire_connectd_peer_reconnected */
|
2025-11-11 16:12:15 +10:30
|
|
|
bool fromwire_connectd_peer_reconnected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, u64 *prev_counter UNNEEDED, u64 *counter UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct wireaddr **remote_addr UNNEEDED, bool *incoming UNNEEDED, u8 **features UNNEEDED, u64 *connected_time_nsec UNNEEDED)
|
2025-09-30 13:38:09 +09:30
|
|
|
{ fprintf(stderr, "fromwire_connectd_peer_reconnected called!\n"); abort(); }
|
2022-07-18 21:42:18 +09:30
|
|
|
/* Generated stub for fromwire_connectd_peer_spoke */
|
2023-10-22 14:37:32 +10:30
|
|
|
bool fromwire_connectd_peer_spoke(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, u64 *counter UNNEEDED, u16 *msgtype UNNEEDED, struct channel_id *channel_id UNNEEDED, wirestring **error UNNEEDED)
|
2022-07-18 21:42:18 +09:30
|
|
|
{ fprintf(stderr, "fromwire_connectd_peer_spoke called!\n"); abort(); }
|
2022-03-08 11:01:26 +10:30
|
|
|
/* Generated stub for fromwire_dualopend_dev_memleak_reply */
|
|
|
|
|
bool fromwire_dualopend_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_dualopend_dev_memleak_reply called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for fromwire_gossipd_addgossip_reply */
|
|
|
|
|
bool fromwire_gossipd_addgossip_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **err UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_gossipd_addgossip_reply called!\n"); abort(); }
|
2025-10-24 13:57:46 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_check_bip86_pubkey_reply */
|
|
|
|
|
bool fromwire_hsmd_check_bip86_pubkey_reply(const void *p UNNEEDED, bool *ok UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_check_bip86_pubkey_reply called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_check_pubkey_reply */
|
|
|
|
|
bool fromwire_hsmd_check_pubkey_reply(const void *p UNNEEDED, bool *ok UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_check_pubkey_reply called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for fromwire_hsmd_client_hsmfd_reply */
|
|
|
|
|
bool fromwire_hsmd_client_hsmfd_reply(const void *p UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_client_hsmfd_reply called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_cupdate_sig_reply */
|
|
|
|
|
bool fromwire_hsmd_cupdate_sig_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **cu UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_cupdate_sig_reply called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_derive_secret_reply */
|
|
|
|
|
bool fromwire_hsmd_derive_secret_reply(const void *p UNNEEDED, struct secret *secret UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_derive_secret_reply called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_ecdh_resp */
|
|
|
|
|
bool fromwire_hsmd_ecdh_resp(const void *p UNNEEDED, struct secret *ss UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_ecdh_resp called!\n"); abort(); }
|
2024-01-25 08:19:20 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_forget_channel_reply */
|
|
|
|
|
bool fromwire_hsmd_forget_channel_reply(const void *p UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_forget_channel_reply called!\n"); abort(); }
|
2020-08-25 11:25:38 +09:30
|
|
|
/* Generated stub for fromwire_hsmd_get_output_scriptpubkey_reply */
|
|
|
|
|
bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_get_output_scriptpubkey_reply called!\n"); abort(); }
|
2025-10-24 13:57:44 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_init_reply_failure */
|
|
|
|
|
bool fromwire_hsmd_init_reply_failure(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u32 *error_code UNNEEDED, wirestring **error_message UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_init_reply_failure called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_init_reply_v4 */
|
2025-10-24 13:57:48 +10:30
|
|
|
bool fromwire_hsmd_init_reply_v4(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u32 *hsm_version UNNEEDED, u32 **hsm_capabilities UNNEEDED, struct node_id *node_id UNNEEDED, struct ext_key *bip32 UNNEEDED, struct pubkey *bolt12 UNNEEDED, struct tlv_hsmd_init_reply_v4_tlvs **tlvs UNNEEDED)
|
2023-03-21 14:28:15 +10:30
|
|
|
{ fprintf(stderr, "fromwire_hsmd_init_reply_v4 called!\n"); abort(); }
|
2021-12-29 10:39:56 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_new_channel_reply */
|
|
|
|
|
bool fromwire_hsmd_new_channel_reply(const void *p UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_new_channel_reply called!\n"); abort(); }
|
2024-01-31 13:46:18 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_node_announcement_sig_reply */
|
|
|
|
|
bool fromwire_hsmd_node_announcement_sig_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_node_announcement_sig_reply called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for fromwire_hsmd_sign_any_cannouncement_reply */
|
|
|
|
|
bool fromwire_hsmd_sign_any_cannouncement_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmd_sign_any_cannouncement_reply called!\n"); abort(); }
|
2020-08-25 11:25:38 +09:30
|
|
|
/* 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(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for fromwire_hsmstatus_client_bad_request */
|
|
|
|
|
bool fromwire_hsmstatus_client_bad_request(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, wirestring **description UNNEEDED, u8 **msg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_hsmstatus_client_bad_request called!\n"); abort(); }
|
2020-08-25 11:45:48 +09:30
|
|
|
/* 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(); }
|
2022-03-08 10:44:41 +10:30
|
|
|
/* Generated stub for fromwire_openingd_dev_memleak_reply */
|
|
|
|
|
bool fromwire_openingd_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "fromwire_openingd_dev_memleak_reply called!\n"); abort(); }
|
2024-03-26 11:53:54 +10:30
|
|
|
/* Generated stub for get_network_blockheight */
|
|
|
|
|
u32 get_network_blockheight(const struct chain_topology *topo UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "get_network_blockheight called!\n"); abort(); }
|
2025-04-29 09:55:08 +09:30
|
|
|
/* Generated stub for hash_cid */
|
|
|
|
|
size_t hash_cid(const struct channel_id *cid UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "hash_cid called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for hsmd_wire_name */
|
|
|
|
|
const char *hsmd_wire_name(int e UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "hsmd_wire_name called!\n"); abort(); }
|
2024-10-22 11:09:50 +10:30
|
|
|
/* Generated stub for htlc_set_add_ */
|
|
|
|
|
void htlc_set_add_(struct lightningd *ld UNNEEDED,
|
|
|
|
|
struct logger *log UNNEEDED,
|
|
|
|
|
struct amount_msat msat UNNEEDED,
|
|
|
|
|
struct amount_msat total_msat UNNEEDED,
|
2025-11-06 16:40:08 +01:00
|
|
|
const struct amount_msat *invoice_msat_override UNNEEDED,
|
2024-10-22 11:09:50 +10:30
|
|
|
const struct sha256 *payment_hash UNNEEDED,
|
|
|
|
|
const struct secret *payment_secret UNNEEDED,
|
|
|
|
|
void (*fail)(void * UNNEEDED, const u8 *) UNNEEDED,
|
|
|
|
|
void (*succeeded)(void * UNNEEDED, const struct preimage *) UNNEEDED,
|
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "htlc_set_add_ called!\n"); abort(); }
|
2023-10-28 11:08:09 +10:30
|
|
|
/* Generated stub for invoice_check_payment */
|
|
|
|
|
const struct invoice_details *invoice_check_payment(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct sha256 *payment_hash UNNEEDED,
|
|
|
|
|
const struct amount_msat msat UNNEEDED,
|
2025-11-06 12:49:23 +01:00
|
|
|
const struct amount_msat *expected_msat_override UNNEEDED,
|
2023-10-28 11:08:09 +10:30
|
|
|
const struct secret *payment_secret UNNEEDED,
|
|
|
|
|
const char **err UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "invoice_check_payment called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for invoices_find_by_rhash */
|
|
|
|
|
bool invoices_find_by_rhash(struct invoices *invoices UNNEEDED,
|
|
|
|
|
u64 *inv_dbid UNNEEDED,
|
|
|
|
|
const struct sha256 *rhash UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "invoices_find_by_rhash called!\n"); abort(); }
|
2018-02-05 14:39:27 +10:30
|
|
|
/* Generated stub for invoices_new */
|
|
|
|
|
struct invoices *invoices_new(const tal_t *ctx UNNEEDED,
|
2023-07-12 05:09:17 +09:30
|
|
|
struct wallet *wallet UNNEEDED,
|
2018-02-05 14:39:27 +10:30
|
|
|
struct timers *timers UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "invoices_new called!\n"); abort(); }
|
2023-10-28 11:08:09 +10:30
|
|
|
/* Generated stub for invoices_resolve */
|
|
|
|
|
bool invoices_resolve(struct invoices *invoices UNNEEDED,
|
|
|
|
|
u64 inv_dbid UNNEEDED,
|
|
|
|
|
struct amount_msat received UNNEEDED,
|
|
|
|
|
const struct json_escape *label UNNEEDED,
|
|
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "invoices_resolve called!\n"); abort(); }
|
2018-02-12 20:42:55 +10:30
|
|
|
/* Generated stub for json_add_log */
|
2018-10-19 11:47:49 +10:30
|
|
|
void json_add_log(struct json_stream *result UNNEEDED,
|
2023-07-16 15:26:52 +09:30
|
|
|
const struct log_book *log_book UNNEEDED,
|
2019-11-18 10:57:15 +10:30
|
|
|
const struct node_id *node_id UNNEEDED,
|
|
|
|
|
enum log_level minlevel UNNEEDED)
|
2018-02-12 20:42:55 +10:30
|
|
|
{ fprintf(stderr, "json_add_log called!\n"); abort(); }
|
2018-02-21 07:29:04 +10:30
|
|
|
/* Generated stub for json_add_uncommitted_channel */
|
2024-06-19 10:06:35 +09:30
|
|
|
void json_add_uncommitted_channel(struct command *cmd UNNEEDED,
|
|
|
|
|
struct json_stream *response UNNEEDED,
|
2024-04-16 11:58:58 +02:00
|
|
|
const struct uncommitted_channel *uc UNNEEDED,
|
|
|
|
|
const struct peer *peer UNNEEDED)
|
2018-02-21 07:29:04 +10:30
|
|
|
{ fprintf(stderr, "json_add_uncommitted_channel called!\n"); abort(); }
|
2021-02-23 20:29:38 -06:00
|
|
|
/* Generated stub for json_add_unsaved_channel */
|
2024-06-19 10:06:35 +09:30
|
|
|
void json_add_unsaved_channel(struct command *cmd UNNEEDED,
|
|
|
|
|
struct json_stream *response UNNEEDED,
|
2024-04-16 11:58:58 +02:00
|
|
|
const struct channel *channel UNNEEDED,
|
|
|
|
|
const struct peer *peer UNNEEDED)
|
2021-02-23 20:29:38 -06:00
|
|
|
{ fprintf(stderr, "json_add_unsaved_channel called!\n"); abort(); }
|
2023-10-28 11:08:09 +10:30
|
|
|
/* Generated stub for json_stream_fail */
|
|
|
|
|
struct json_stream *json_stream_fail(struct command *cmd UNNEEDED,
|
|
|
|
|
enum jsonrpc_errcode code UNNEEDED,
|
|
|
|
|
const char *errmsg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "json_stream_fail called!\n"); abort(); }
|
2018-10-19 11:47:48 +10:30
|
|
|
/* Generated stub for json_stream_success */
|
2018-10-19 11:47:49 +10:30
|
|
|
struct json_stream *json_stream_success(struct command *cmd UNNEEDED)
|
2018-10-19 11:47:48 +10:30
|
|
|
{ fprintf(stderr, "json_stream_success called!\n"); abort(); }
|
2018-02-21 07:29:04 +10:30
|
|
|
/* Generated stub for kill_uncommitted_channel */
|
|
|
|
|
void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,
|
|
|
|
|
const char *why UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "kill_uncommitted_channel called!\n"); abort(); }
|
2023-10-02 09:29:49 +10:30
|
|
|
/* Generated stub for lockin_complete */
|
|
|
|
|
void lockin_complete(struct channel *channel UNNEEDED,
|
|
|
|
|
enum channel_state expected_state UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "lockin_complete called!\n"); abort(); }
|
2023-06-30 04:53:08 +09:30
|
|
|
/* Generated stub for logv */
|
2023-07-16 15:26:52 +09:30
|
|
|
void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
|
2023-06-30 04:53:08 +09:30
|
|
|
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "logv called!\n"); abort(); }
|
2020-04-14 14:01:18 -05:00
|
|
|
/* Generated stub for new_channel_mvt_invoice_hin */
|
|
|
|
|
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx UNNEEDED,
|
2025-08-14 10:57:53 +09:30
|
|
|
const struct htlc_in *hin UNNEEDED,
|
|
|
|
|
const struct channel *channel UNNEEDED)
|
2020-04-14 14:01:18 -05:00
|
|
|
{ fprintf(stderr, "new_channel_mvt_invoice_hin called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for new_channel_mvt_invoice_hout */
|
|
|
|
|
struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx UNNEEDED,
|
2025-08-14 10:57:53 +09:30
|
|
|
const struct htlc_out *hout UNNEEDED,
|
|
|
|
|
const struct channel *channel UNNEEDED)
|
2020-04-14 14:01:18 -05:00
|
|
|
{ fprintf(stderr, "new_channel_mvt_invoice_hout called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for new_channel_mvt_routed_hin */
|
|
|
|
|
struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx UNNEEDED,
|
2025-08-14 10:57:53 +09:30
|
|
|
const struct htlc_in *hin UNNEEDED,
|
|
|
|
|
const struct channel *channel UNNEEDED)
|
2020-04-14 14:01:18 -05:00
|
|
|
{ fprintf(stderr, "new_channel_mvt_routed_hin called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for new_channel_mvt_routed_hout */
|
|
|
|
|
struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx UNNEEDED,
|
2025-08-14 10:57:53 +09:30
|
|
|
const struct htlc_out *hout UNNEEDED,
|
|
|
|
|
const struct channel *channel UNNEEDED)
|
2020-04-14 14:01:18 -05:00
|
|
|
{ fprintf(stderr, "new_channel_mvt_routed_hout called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for new_global_subd */
|
|
|
|
|
struct subd *new_global_subd(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const char *name UNNEEDED,
|
|
|
|
|
const char *(*msgname)(int msgtype) UNNEEDED,
|
|
|
|
|
unsigned int (*msgcb)(struct subd * UNNEEDED, const u8 * UNNEEDED,
|
|
|
|
|
const int *fds) UNNEEDED,
|
|
|
|
|
...)
|
|
|
|
|
{ fprintf(stderr, "new_global_subd called!\n"); abort(); }
|
2022-01-11 11:43:59 +10:30
|
|
|
/* Generated stub for new_peer_fd */
|
2022-01-29 14:03:05 +10:30
|
|
|
struct peer_fd *new_peer_fd(const tal_t *ctx UNNEEDED, int peer_fd UNNEEDED)
|
2022-01-11 11:43:59 +10:30
|
|
|
{ fprintf(stderr, "new_peer_fd called!\n"); abort(); }
|
2022-03-23 06:57:29 +10:30
|
|
|
/* Generated stub for new_uncommitted_channel */
|
|
|
|
|
struct uncommitted_channel *new_uncommitted_channel(struct peer *peer UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "new_uncommitted_channel called!\n"); abort(); }
|
2024-01-31 13:46:19 +10:30
|
|
|
/* Generated stub for node_announcement_same */
|
|
|
|
|
bool node_announcement_same(const u8 *nann1 UNNEEDED, const u8 *nann2 UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "node_announcement_same called!\n"); abort(); }
|
2020-04-01 21:55:44 -05:00
|
|
|
/* Generated stub for notify_chain_mvt */
|
2025-08-14 10:57:53 +09:30
|
|
|
void notify_chain_mvt(struct lightningd *ld UNNEEDED,
|
2025-08-19 10:30:46 +09:30
|
|
|
const struct chain_coin_mvt *chain_mvt UNNEEDED,
|
|
|
|
|
u64 id UNNEEDED)
|
2020-04-01 21:55:44 -05:00
|
|
|
{ fprintf(stderr, "notify_chain_mvt called!\n"); abort(); }
|
2020-03-18 18:40:32 -05:00
|
|
|
/* Generated stub for notify_channel_mvt */
|
2025-08-14 10:57:53 +09:30
|
|
|
void notify_channel_mvt(struct lightningd *ld UNNEEDED,
|
2025-08-19 10:30:46 +09:30
|
|
|
const struct channel_coin_mvt *chan_mvt UNNEEDED,
|
|
|
|
|
u64 id UNNEEDED)
|
2020-03-18 18:40:32 -05:00
|
|
|
{ fprintf(stderr, "notify_channel_mvt called!\n"); abort(); }
|
2021-02-08 16:47:19 -06:00
|
|
|
/* Generated stub for notify_channel_open_failed */
|
|
|
|
|
void notify_channel_open_failed(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct channel_id *cid UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "notify_channel_open_failed called!\n"); abort(); }
|
2018-12-13 13:58:40 +01:00
|
|
|
/* Generated stub for notify_connect */
|
2021-03-25 14:23:31 +10:30
|
|
|
void notify_connect(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct node_id *nodeid UNNEEDED,
|
|
|
|
|
bool incoming UNNEEDED,
|
|
|
|
|
const struct wireaddr_internal *addr UNNEEDED)
|
2018-12-13 13:58:40 +01:00
|
|
|
{ fprintf(stderr, "notify_connect called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for notify_disconnect */
|
2025-09-30 13:38:09 +09:30
|
|
|
void notify_disconnect(struct lightningd *ld UNNEEDED, const struct node_id *nodeid UNNEEDED)
|
2018-12-13 13:58:40 +01:00
|
|
|
{ fprintf(stderr, "notify_disconnect called!\n"); abort(); }
|
2019-06-16 00:50:07 +08:00
|
|
|
/* Generated stub for notify_forward_event */
|
2019-08-06 17:49:26 +02:00
|
|
|
void notify_forward_event(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct htlc_in *in UNNEEDED,
|
2020-02-13 12:41:01 +10:30
|
|
|
/* May be NULL if we don't know. */
|
|
|
|
|
const struct short_channel_id *scid_out UNNEEDED,
|
|
|
|
|
/* May be NULL. */
|
|
|
|
|
const struct amount_msat *amount_out UNNEEDED,
|
2019-08-06 17:49:26 +02:00
|
|
|
enum forward_status state UNNEEDED,
|
2020-08-31 10:43:25 +09:30
|
|
|
enum onion_wire failcode UNNEEDED,
|
2022-03-31 13:44:27 +10:30
|
|
|
struct timeabs *resolved_time UNNEEDED,
|
2023-10-28 13:42:06 +10:30
|
|
|
enum forward_style forward_style UNNEEDED,
|
|
|
|
|
u64 created_index UNNEEDED,
|
|
|
|
|
u64 updated_index UNNEEDED)
|
2019-08-06 17:49:26 +02:00
|
|
|
{ fprintf(stderr, "notify_forward_event called!\n"); abort(); }
|
2023-10-28 11:08:09 +10:30
|
|
|
/* Generated stub for notify_invoice_payment */
|
2024-01-25 08:19:20 +10:30
|
|
|
void notify_invoice_payment(struct lightningd *ld UNNEEDED,
|
|
|
|
|
struct amount_msat amount UNNEEDED,
|
|
|
|
|
const struct preimage *preimage UNNEEDED,
|
|
|
|
|
const struct json_escape *label UNNEEDED,
|
2023-10-28 11:08:09 +10:30
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "notify_invoice_payment called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for notify_sendpay_failure */
|
|
|
|
|
void notify_sendpay_failure(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct wallet_payment *payment UNNEEDED,
|
|
|
|
|
enum jsonrpc_errcode pay_errcode UNNEEDED,
|
|
|
|
|
const struct onionreply *onionreply UNNEEDED,
|
|
|
|
|
const struct routing_failure *fail UNNEEDED,
|
|
|
|
|
const char *errmsg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "notify_sendpay_failure called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for notify_sendpay_success */
|
|
|
|
|
void notify_sendpay_success(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct wallet_payment *payment UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "notify_sendpay_success called!\n"); abort(); }
|
2018-04-16 13:20:45 +02:00
|
|
|
/* Generated stub for onchaind_funding_spent */
|
|
|
|
|
enum watch_result onchaind_funding_spent(struct channel *channel UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx *tx UNNEEDED,
|
2021-12-01 10:24:31 -06:00
|
|
|
u32 blockheight UNNEEDED)
|
2018-04-16 13:20:45 +02:00
|
|
|
{ fprintf(stderr, "onchaind_funding_spent called!\n"); abort(); }
|
2018-02-26 14:57:13 +01:00
|
|
|
/* Generated stub for outpointfilter_add */
|
|
|
|
|
void outpointfilter_add(struct outpointfilter *of UNNEEDED,
|
2021-10-13 14:15:36 +10:30
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
2018-02-26 14:57:13 +01:00
|
|
|
{ fprintf(stderr, "outpointfilter_add called!\n"); abort(); }
|
2018-03-02 15:07:13 +01:00
|
|
|
/* Generated stub for outpointfilter_matches */
|
|
|
|
|
bool outpointfilter_matches(struct outpointfilter *of UNNEEDED,
|
2021-10-13 14:15:36 +10:30
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
2018-03-02 15:07:13 +01:00
|
|
|
{ fprintf(stderr, "outpointfilter_matches called!\n"); abort(); }
|
2018-02-26 14:57:13 +01:00
|
|
|
/* Generated stub for outpointfilter_new */
|
|
|
|
|
struct outpointfilter *outpointfilter_new(tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "outpointfilter_new called!\n"); abort(); }
|
2021-01-07 14:27:54 +01:00
|
|
|
/* Generated stub for outpointfilter_remove */
|
|
|
|
|
void outpointfilter_remove(struct outpointfilter *of UNNEEDED,
|
2021-10-13 14:15:36 +10:30
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
2021-01-07 14:27:54 +01:00
|
|
|
{ fprintf(stderr, "outpointfilter_remove called!\n"); abort(); }
|
2018-12-16 15:20:06 +10:30
|
|
|
/* Generated stub for param_loglevel */
|
|
|
|
|
struct command_result *param_loglevel(struct command *cmd UNNEEDED,
|
|
|
|
|
const char *name UNNEEDED,
|
|
|
|
|
const char *buffer UNNEEDED,
|
|
|
|
|
const jsmntok_t *tok UNNEEDED,
|
|
|
|
|
enum log_level **level UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "param_loglevel called!\n"); abort(); }
|
2021-01-07 19:05:06 -06:00
|
|
|
/* Generated stub for peer_restart_dualopend */
|
2022-07-18 21:42:18 +09:30
|
|
|
bool peer_restart_dualopend(struct peer *peer UNNEEDED,
|
2022-01-11 11:43:59 +10:30
|
|
|
struct peer_fd *peer_fd UNNEEDED,
|
2023-07-29 20:41:26 -05:00
|
|
|
struct channel *channel UNNEEDED,
|
|
|
|
|
bool from_abort UNNEEDED)
|
2021-01-07 19:05:06 -06:00
|
|
|
{ fprintf(stderr, "peer_restart_dualopend called!\n"); abort(); }
|
2018-02-21 07:29:09 +10:30
|
|
|
/* Generated stub for peer_start_channeld */
|
2022-07-18 21:42:18 +09:30
|
|
|
bool peer_start_channeld(struct channel *channel UNNEEDED,
|
2022-01-11 11:43:59 +10:30
|
|
|
struct peer_fd *peer_fd UNNEEDED,
|
2020-09-10 14:34:18 -05:00
|
|
|
const u8 *fwd_msg UNNEEDED,
|
2025-04-29 09:55:09 +09:30
|
|
|
bool reconnected UNNEEDED)
|
2018-02-21 07:29:09 +10:30
|
|
|
{ fprintf(stderr, "peer_start_channeld called!\n"); abort(); }
|
2020-09-09 19:40:28 +09:30
|
|
|
/* Generated stub for peer_start_dualopend */
|
2022-03-23 06:57:29 +10:30
|
|
|
bool peer_start_dualopend(struct peer *peer UNNEEDED, struct peer_fd *peer_fd UNNEEDED,
|
|
|
|
|
struct channel *channel UNNEEDED)
|
2020-09-09 19:40:28 +09:30
|
|
|
{ fprintf(stderr, "peer_start_dualopend called!\n"); abort(); }
|
openingd: take peer before we're opening, wait for explicit funding msg.
Prior to this, lightningd would hand uninteresting peers back to connectd,
which would then return it to lightningd if it sent a non-gossip msg,
or if lightningd asked it to release the peer.
Now connectd hands the peer to lightningd once we've done the init
handshake, which hands it off to openingd.
This is a deep structural change, so we do the minimum here and cleanup
in the following patches.
Lightningd:
1. Remove peer_nongossip handling from connect_control and peer_control.
2. Remove list of outstanding fundchannel command; it was only needed to
find the race between us asking connectd to release the peer and it
reconnecting.
3. We can no longer tell if the remote end has started trying to fund a
channel (until it has succeeded): it's very transitory anyway so not
worth fixing.
4. We now always have a struct peer, and allocate an uncommitted_channel
for it, though it may never be used if neither end funds a channel.
5. We start funding on messages for openingd: we can get a funder_reply
or a fundee, or an error in response to our request to fund a channel.
so we handle all of them.
6. A new peer_start_openingd() is called after connectd hands us a peer.
7. json_fund_channel just looks through local peers; there are none
hidden in connectd any more.
8. We sometimes start a new openingd just to send an error message.
Openingd:
1. We always have information we need to accept them funding a channel (in
the init message).
2. We have to listen for three fds: peer, gossip and master, so we opencode
the poll.
3. We have an explicit message to start trying to fund a channel.
4. We can be told to send a message in our init message.
Testing:
1. We don't handle some things gracefully yet, so two tests are disabled.
2. 'hand_back_peer .*: now local again' from connectd is no longer a message,
openingd says 'Handed peer, entering loop' once its managing it.
3. peer['state'] used to be set to 'GOSSIPING' (otherwise this field doesn't
exist; 'state' is now per-channel. It doesn't exist at all now.
4. Some tests now need to turn on IO logging in openingd, not connectd.
5. There's a gap between connecting on one node and having connectd on
the peer hand over the connection to openingd. Our tests sometimes
checked getpeers() on the peer, and didn't see anything, so line_graph
needed updating.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-08 23:40:58 +09:30
|
|
|
/* Generated stub for peer_start_openingd */
|
2022-03-23 06:57:29 +10:30
|
|
|
bool peer_start_openingd(struct peer *peer UNNEEDED,
|
2022-01-11 11:43:59 +10:30
|
|
|
struct peer_fd *peer_fd UNNEEDED)
|
openingd: take peer before we're opening, wait for explicit funding msg.
Prior to this, lightningd would hand uninteresting peers back to connectd,
which would then return it to lightningd if it sent a non-gossip msg,
or if lightningd asked it to release the peer.
Now connectd hands the peer to lightningd once we've done the init
handshake, which hands it off to openingd.
This is a deep structural change, so we do the minimum here and cleanup
in the following patches.
Lightningd:
1. Remove peer_nongossip handling from connect_control and peer_control.
2. Remove list of outstanding fundchannel command; it was only needed to
find the race between us asking connectd to release the peer and it
reconnecting.
3. We can no longer tell if the remote end has started trying to fund a
channel (until it has succeeded): it's very transitory anyway so not
worth fixing.
4. We now always have a struct peer, and allocate an uncommitted_channel
for it, though it may never be used if neither end funds a channel.
5. We start funding on messages for openingd: we can get a funder_reply
or a fundee, or an error in response to our request to fund a channel.
so we handle all of them.
6. A new peer_start_openingd() is called after connectd hands us a peer.
7. json_fund_channel just looks through local peers; there are none
hidden in connectd any more.
8. We sometimes start a new openingd just to send an error message.
Openingd:
1. We always have information we need to accept them funding a channel (in
the init message).
2. We have to listen for three fds: peer, gossip and master, so we opencode
the poll.
3. We have an explicit message to start trying to fund a channel.
4. We can be told to send a message in our init message.
Testing:
1. We don't handle some things gracefully yet, so two tests are disabled.
2. 'hand_back_peer .*: now local again' from connectd is no longer a message,
openingd says 'Handed peer, entering loop' once its managing it.
3. peer['state'] used to be set to 'GOSSIPING' (otherwise this field doesn't
exist; 'state' is now per-channel. It doesn't exist at all now.
4. Some tests now need to turn on IO logging in openingd, not connectd.
5. There's a gap between connecting on one node and having connectd on
the peer hand over the connection to openingd. Our tests sometimes
checked getpeers() on the peer, and didn't see anything, so line_graph
needed updating.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-08 23:40:58 +09:30
|
|
|
{ fprintf(stderr, "peer_start_openingd called!\n"); abort(); }
|
2019-01-19 15:56:05 +01:00
|
|
|
/* Generated stub for plugin_hook_call_ */
|
2022-09-13 06:49:12 +09:30
|
|
|
bool plugin_hook_call_(struct lightningd *ld UNNEEDED,
|
2025-11-20 12:07:06 +10:30
|
|
|
struct plugin_hook *hook UNNEEDED,
|
2025-11-20 12:07:13 +10:30
|
|
|
const char *strfilterfield TAKES UNNEEDED,
|
|
|
|
|
u64 intfilterfield UNNEEDED,
|
2022-09-13 06:49:12 +09:30
|
|
|
const char *cmd_id TAKES UNNEEDED,
|
2020-05-04 16:49:53 +09:30
|
|
|
tal_t *cb_arg STEALS UNNEEDED)
|
2019-01-19 15:56:05 +01:00
|
|
|
{ fprintf(stderr, "plugin_hook_call_ called!\n"); abort(); }
|
2023-03-30 15:55:21 +10:30
|
|
|
/* Generated stub for psbt_fixup */
|
|
|
|
|
const u8 *psbt_fixup(const tal_t *ctx UNNEEDED, const u8 *psbtblob UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "psbt_fixup called!\n"); abort(); }
|
2022-03-08 10:44:41 +10:30
|
|
|
/* Generated stub for report_subd_memleak */
|
|
|
|
|
void report_subd_memleak(struct leak_detect *leak_detect UNNEEDED, struct subd *leaker UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "report_subd_memleak called!\n"); abort(); }
|
2021-09-15 10:29:23 +09:30
|
|
|
/* Generated stub for resolve_close_command */
|
2023-07-31 21:03:22 +09:30
|
|
|
void resolve_close_command(struct lightningd *ld UNNEEDED, struct channel *channel UNNEEDED,
|
2024-11-25 15:40:06 +10:30
|
|
|
bool cooperative UNNEEDED, const struct bitcoin_tx **close_txs UNNEEDED)
|
2021-09-15 10:29:23 +09:30
|
|
|
{ fprintf(stderr, "resolve_close_command called!\n"); abort(); }
|
2023-09-21 15:04:59 +09:30
|
|
|
/* Generated stub for rune_unique_id */
|
|
|
|
|
u64 rune_unique_id(const struct rune *rune UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "rune_unique_id called!\n"); abort(); }
|
2022-03-08 10:44:41 +10:30
|
|
|
/* Generated stub for start_leak_request */
|
|
|
|
|
void start_leak_request(const struct subd_req *req UNNEEDED,
|
|
|
|
|
struct leak_detect *leak_detect UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "start_leak_request called!\n"); abort(); }
|
2018-02-12 20:43:04 +10:30
|
|
|
/* Generated stub for subd_release_channel */
|
2021-12-28 09:51:09 +10:30
|
|
|
void subd_release_channel(struct subd *owner UNNEEDED, const void *channel UNNEEDED)
|
2018-02-12 20:43:04 +10:30
|
|
|
{ fprintf(stderr, "subd_release_channel called!\n"); abort(); }
|
2018-02-12 20:42:55 +10:30
|
|
|
/* Generated stub for subd_req_ */
|
2022-03-08 10:44:41 +10:30
|
|
|
struct subd_req *subd_req_(const tal_t *ctx UNNEEDED,
|
2018-02-12 20:42:55 +10:30
|
|
|
struct subd *sd UNNEEDED,
|
|
|
|
|
const u8 *msg_out UNNEEDED,
|
|
|
|
|
int fd_out UNNEEDED, size_t num_fds_in UNNEEDED,
|
|
|
|
|
void (*replycb)(struct subd * UNNEEDED, const u8 * UNNEEDED, const int * UNNEEDED, void *) UNNEEDED,
|
2024-11-13 13:24:28 +10:30
|
|
|
void *replycb_data TAKES UNNEEDED)
|
2018-02-12 20:42:55 +10:30
|
|
|
{ fprintf(stderr, "subd_req_ called!\n"); abort(); }
|
2022-07-18 21:42:18 +09:30
|
|
|
/* Generated stub for subd_send_fd */
|
|
|
|
|
void subd_send_fd(struct subd *sd UNNEEDED, int fd UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "subd_send_fd called!\n"); abort(); }
|
2018-02-12 20:42:55 +10:30
|
|
|
/* Generated stub for subd_send_msg */
|
|
|
|
|
void subd_send_msg(struct subd *sd UNNEEDED, const u8 *msg_out UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "subd_send_msg called!\n"); abort(); }
|
2024-11-25 11:38:15 +10:30
|
|
|
/* Generated stub for tell_connectd_peer_importance */
|
|
|
|
|
void tell_connectd_peer_importance(struct peer *peer UNNEEDED,
|
|
|
|
|
bool was_important UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "tell_connectd_peer_importance called!\n"); abort(); }
|
2024-04-04 14:06:13 +10:30
|
|
|
/* Generated stub for tlv_hsmd_dev_preinit_tlvs_new */
|
|
|
|
|
struct tlv_hsmd_dev_preinit_tlvs *tlv_hsmd_dev_preinit_tlvs_new(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "tlv_hsmd_dev_preinit_tlvs_new called!\n"); abort(); }
|
2025-10-24 13:57:43 +10:30
|
|
|
/* Generated stub for tlv_hsmd_init_tlvs_new */
|
|
|
|
|
struct tlv_hsmd_init_tlvs *tlv_hsmd_init_tlvs_new(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "tlv_hsmd_init_tlvs_new called!\n"); abort(); }
|
2019-08-10 20:18:13 +09:30
|
|
|
/* Generated stub for topology_add_sync_waiter_ */
|
|
|
|
|
void topology_add_sync_waiter_(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
2022-07-25 16:31:09 +09:30
|
|
|
void (*cb)(struct chain_topology * UNNEEDED,
|
|
|
|
|
void *) UNNEEDED,
|
2019-08-10 20:18:13 +09:30
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "topology_add_sync_waiter_ called!\n"); abort(); }
|
2020-08-25 11:03:16 +09:30
|
|
|
/* Generated stub for towire_channeld_dev_memleak */
|
|
|
|
|
u8 *towire_channeld_dev_memleak(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_dev_memleak called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_dev_reenable_commit */
|
|
|
|
|
u8 *towire_channeld_dev_reenable_commit(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_dev_reenable_commit called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_fail_htlc */
|
|
|
|
|
u8 *towire_channeld_fail_htlc(const tal_t *ctx UNNEEDED, const struct failed_htlc *failed_htlc UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_fail_htlc called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_fulfill_htlc */
|
|
|
|
|
u8 *towire_channeld_fulfill_htlc(const tal_t *ctx UNNEEDED, const struct fulfilled_htlc *fulfilled_htlc UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_fulfill_htlc called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_got_commitsig_reply */
|
|
|
|
|
u8 *towire_channeld_got_commitsig_reply(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_got_commitsig_reply called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_got_revoke_reply */
|
|
|
|
|
u8 *towire_channeld_got_revoke_reply(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_got_revoke_reply called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_offer_htlc */
|
2025-07-30 13:55:20 +02:00
|
|
|
u8 *towire_channeld_offer_htlc(const tal_t *ctx UNNEEDED, struct amount_msat amount_msat UNNEEDED, u32 cltv_expiry UNNEEDED, const struct sha256 *payment_hash UNNEEDED, const u8 onion_routing_packet[1366] UNNEEDED, const struct pubkey *path_key UNNEEDED, const u8 *extra_tlvs UNNEEDED)
|
2020-08-25 11:03:16 +09:30
|
|
|
{ fprintf(stderr, "towire_channeld_offer_htlc called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_channeld_sending_commitsig_reply */
|
|
|
|
|
u8 *towire_channeld_sending_commitsig_reply(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_channeld_sending_commitsig_reply called!\n"); abort(); }
|
2024-11-25 11:38:15 +10:30
|
|
|
/* Generated stub for towire_connectd_disconnect_peer */
|
|
|
|
|
u8 *towire_connectd_disconnect_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u64 counter UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_connectd_disconnect_peer called!\n"); abort(); }
|
2022-07-18 21:42:18 +09:30
|
|
|
/* Generated stub for towire_connectd_peer_connect_subd */
|
2022-07-18 21:42:27 +09:30
|
|
|
u8 *towire_connectd_peer_connect_subd(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u64 counter UNNEEDED, const struct channel_id *channel_id UNNEEDED)
|
2022-07-18 21:42:18 +09:30
|
|
|
{ fprintf(stderr, "towire_connectd_peer_connect_subd called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for towire_connectd_peer_send_msg */
|
|
|
|
|
u8 *towire_connectd_peer_send_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u64 counter UNNEEDED, const u8 *msg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_connectd_peer_send_msg called!\n"); abort(); }
|
2022-03-08 11:01:26 +10:30
|
|
|
/* Generated stub for towire_dualopend_dev_memleak */
|
|
|
|
|
u8 *towire_dualopend_dev_memleak(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_dualopend_dev_memleak called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for towire_gossipd_addgossip */
|
2024-01-31 15:03:12 +10:30
|
|
|
u8 *towire_gossipd_addgossip(const tal_t *ctx UNNEEDED, const u8 *msg UNNEEDED, struct amount_sat *known_channel UNNEEDED)
|
2024-01-31 13:46:17 +10:30
|
|
|
{ fprintf(stderr, "towire_gossipd_addgossip called!\n"); abort(); }
|
2025-10-24 13:57:46 +10:30
|
|
|
/* Generated stub for towire_hsmd_check_bip86_pubkey */
|
|
|
|
|
u8 *towire_hsmd_check_bip86_pubkey(const tal_t *ctx UNNEEDED, u32 index UNNEEDED, const struct pubkey *pubkey UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_check_bip86_pubkey called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for towire_hsmd_check_pubkey */
|
|
|
|
|
u8 *towire_hsmd_check_pubkey(const tal_t *ctx UNNEEDED, u32 index UNNEEDED, const struct pubkey *pubkey UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_check_pubkey called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for towire_hsmd_client_hsmfd */
|
2023-09-12 10:13:04 +09:30
|
|
|
u8 *towire_hsmd_client_hsmfd(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u64 dbid UNNEEDED, u64 permissions UNNEEDED)
|
2023-03-21 14:28:15 +10:30
|
|
|
{ fprintf(stderr, "towire_hsmd_client_hsmfd called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for towire_hsmd_cupdate_sig_req */
|
|
|
|
|
u8 *towire_hsmd_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_cupdate_sig_req called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for towire_hsmd_derive_secret */
|
|
|
|
|
u8 *towire_hsmd_derive_secret(const tal_t *ctx UNNEEDED, const u8 *info UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_derive_secret called!\n"); abort(); }
|
2024-04-04 14:06:13 +10:30
|
|
|
/* Generated stub for towire_hsmd_dev_preinit */
|
|
|
|
|
u8 *towire_hsmd_dev_preinit(const tal_t *ctx UNNEEDED, const struct tlv_hsmd_dev_preinit_tlvs *tlvs UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_dev_preinit called!\n"); abort(); }
|
2025-10-22 19:44:26 +10:30
|
|
|
/* Generated stub for towire_hsmd_ecdh_req */
|
|
|
|
|
u8 *towire_hsmd_ecdh_req(const tal_t *ctx UNNEEDED, const struct pubkey *point UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_ecdh_req called!\n"); abort(); }
|
2024-01-25 08:19:20 +10:30
|
|
|
/* Generated stub for towire_hsmd_forget_channel */
|
|
|
|
|
u8 *towire_hsmd_forget_channel(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u64 dbid UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_forget_channel called!\n"); abort(); }
|
2020-08-25 11:25:38 +09:30
|
|
|
/* Generated stub for towire_hsmd_get_output_scriptpubkey */
|
|
|
|
|
u8 *towire_hsmd_get_output_scriptpubkey(const tal_t *ctx UNNEEDED, u64 channel_id UNNEEDED, const struct node_id *peer_id UNNEEDED, const struct pubkey *commitment_point UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_get_output_scriptpubkey called!\n"); abort(); }
|
2023-03-21 14:28:15 +10:30
|
|
|
/* Generated stub for towire_hsmd_init */
|
2025-10-24 13:57:43 +10:30
|
|
|
u8 *towire_hsmd_init(const tal_t *ctx UNNEEDED, const struct bip32_key_version *bip32_key_version UNNEEDED, const struct chainparams *chainparams UNNEEDED, const struct secret *hsm_encryption_key UNNEEDED, const struct privkey *dev_force_privkey UNNEEDED, const struct secret *dev_force_bip32_seed UNNEEDED, const struct secrets *dev_force_channel_secrets UNNEEDED, const struct sha256 *dev_force_channel_secrets_shaseed UNNEEDED, u32 hsm_wire_min_version UNNEEDED, u32 hsm_wire_max_version UNNEEDED, const struct tlv_hsmd_init_tlvs *tlvs UNNEEDED)
|
2023-03-21 14:28:15 +10:30
|
|
|
{ fprintf(stderr, "towire_hsmd_init called!\n"); abort(); }
|
2021-12-29 10:39:56 +10:30
|
|
|
/* Generated stub for towire_hsmd_new_channel */
|
|
|
|
|
u8 *towire_hsmd_new_channel(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u64 dbid UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_new_channel called!\n"); abort(); }
|
2024-01-31 13:46:18 +10:30
|
|
|
/* Generated stub for towire_hsmd_node_announcement_sig_req */
|
|
|
|
|
u8 *towire_hsmd_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_node_announcement_sig_req called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for towire_hsmd_sign_any_cannouncement_req */
|
|
|
|
|
u8 *towire_hsmd_sign_any_cannouncement_req(const tal_t *ctx UNNEEDED, const u8 *ca UNNEEDED, const struct node_id *peerid UNNEEDED, u64 channel_dbid UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_hsmd_sign_any_cannouncement_req called!\n"); abort(); }
|
2020-08-25 11:25:38 +09:30
|
|
|
/* Generated stub for towire_hsmd_sign_commitment_tx */
|
2021-12-14 17:37:35 -08:00
|
|
|
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED, u64 commit_num UNNEEDED)
|
2020-08-25 11:25:38 +09:30
|
|
|
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
|
2020-08-25 11:45:48 +09:30
|
|
|
/* 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 */
|
2021-12-01 10:24:31 -06:00
|
|
|
u8 *towire_onchaind_known_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED)
|
2020-08-25 11:45:48 +09:30
|
|
|
{ fprintf(stderr, "towire_onchaind_known_preimage called!\n"); abort(); }
|
2022-03-08 10:44:41 +10:30
|
|
|
/* Generated stub for towire_openingd_dev_memleak */
|
|
|
|
|
u8 *towire_openingd_dev_memleak(const tal_t *ctx UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "towire_openingd_dev_memleak called!\n"); abort(); }
|
2024-01-31 13:46:17 +10:30
|
|
|
/* Generated stub for unsigned_channel_update */
|
|
|
|
|
u8 *unsigned_channel_update(const tal_t *ctx UNNEEDED,
|
|
|
|
|
const struct channel *channel UNNEEDED,
|
2024-03-20 12:29:51 +10:30
|
|
|
struct short_channel_id scid UNNEEDED,
|
2024-01-31 13:46:17 +10:30
|
|
|
const u32 *old_timestamp UNNEEDED,
|
|
|
|
|
bool forwardable UNNEEDED,
|
|
|
|
|
bool enabled UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "unsigned_channel_update called!\n"); abort(); }
|
2024-01-31 13:46:18 +10:30
|
|
|
/* Generated stub for unsigned_node_announcement */
|
2024-01-31 13:46:20 +10:30
|
|
|
u8 *unsigned_node_announcement(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct lightningd *ld UNNEEDED,
|
|
|
|
|
const u8 *prev UNNEEDED)
|
2024-01-31 13:46:18 +10:30
|
|
|
{ fprintf(stderr, "unsigned_node_announcement called!\n"); abort(); }
|
2023-10-02 09:29:51 +10:30
|
|
|
/* Generated stub for watch_opening_inflight */
|
|
|
|
|
void watch_opening_inflight(struct lightningd *ld UNNEEDED,
|
|
|
|
|
struct channel_inflight *inflight UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "watch_opening_inflight called!\n"); abort(); }
|
|
|
|
|
/* Generated stub for watch_splice_inflight */
|
|
|
|
|
void watch_splice_inflight(struct lightningd *ld UNNEEDED,
|
|
|
|
|
struct channel_inflight *inflight UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "watch_splice_inflight called!\n"); abort(); }
|
2023-10-02 09:29:51 +10:30
|
|
|
/* Generated stub for watch_txid_ */
|
|
|
|
|
struct txwatch *watch_txid_(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
|
enum watch_result (*cb)(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct bitcoin_txid * UNNEEDED,
|
|
|
|
|
const struct bitcoin_tx * UNNEEDED,
|
|
|
|
|
unsigned int depth UNNEEDED,
|
|
|
|
|
void *arg) UNNEEDED,
|
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
|
{ fprintf(stderr, "watch_txid_ called!\n"); abort(); }
|
2018-02-21 07:29:09 +10:30
|
|
|
/* Generated stub for watch_txo */
|
|
|
|
|
struct txowatch *watch_txo(const tal_t *ctx UNNEEDED,
|
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
|
|
|
|
struct channel *channel UNNEEDED,
|
2021-10-13 14:15:36 +10:30
|
|
|
const struct bitcoin_outpoint *outpoint UNNEEDED,
|
2022-07-25 16:31:09 +09:30
|
|
|
enum watch_result (*cb)(struct channel * UNNEEDED,
|
2018-02-21 07:29:09 +10:30
|
|
|
const struct bitcoin_tx *tx UNNEEDED,
|
|
|
|
|
size_t input_num UNNEEDED,
|
|
|
|
|
const struct block *block))
|
|
|
|
|
{ fprintf(stderr, "watch_txo called!\n"); abort(); }
|
2017-12-12 14:12:38 +10:30
|
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
|
|
2018-07-23 11:53:03 +09:30
|
|
|
/* Fake stubs to talk to hsm */
|
2020-08-25 11:25:38 +09:30
|
|
|
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
|
2018-07-23 11:53:03 +09:30
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2019-12-18 11:06:09 +01:00
|
|
|
void plugin_hook_db_sync(struct db *db UNNEEDED)
|
2019-03-18 13:10:32 +10:30
|
|
|
{
|
|
|
|
|
}
|
2025-11-18 11:04:56 +10:30
|
|
|
void notify_channel_state_changed(struct lightningd *ld UNNEEDED,
|
|
|
|
|
const struct node_id *peer_id UNNEEDED,
|
|
|
|
|
const struct channel_id *cid UNNEEDED,
|
|
|
|
|
const struct short_channel_id *scid UNNEEDED,
|
|
|
|
|
struct timeabs timestamp UNNEEDED,
|
|
|
|
|
enum channel_state old_state UNNEEDED,
|
|
|
|
|
enum channel_state new_state UNNEEDED,
|
|
|
|
|
enum state_change cause UNNEEDED,
|
|
|
|
|
const char *message UNNEEDED)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-08-25 11:25:38 +09:30
|
|
|
bool fromwire_hsmd_get_channel_basepoints_reply(const void *p UNNEEDED,
|
2018-07-23 11:53:03 +09:30
|
|
|
struct basepoints *basepoints,
|
|
|
|
|
struct pubkey *funding_pubkey)
|
|
|
|
|
{
|
2021-03-01 20:45:39 +01:00
|
|
|
struct pubkey pk;
|
|
|
|
|
pubkey_from_der(tal_hexdata(tmpctx,
|
|
|
|
|
"02a1633cafcc01ebfb6d78e39f687a1f0995c62fc9"
|
|
|
|
|
"5f51ead10a02ee0be551b5dc",
|
|
|
|
|
66),
|
|
|
|
|
33, &pk);
|
|
|
|
|
*funding_pubkey = pk;
|
|
|
|
|
basepoints->revocation = pk;
|
|
|
|
|
basepoints->payment = pk;
|
|
|
|
|
basepoints->htlc = pk;
|
|
|
|
|
basepoints->delayed_payment = pk;
|
2018-07-23 11:53:03 +09:30
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-01 11:40:48 +10:30
|
|
|
#define transaction_wrap(db, ...) \
|
2017-11-01 11:51:56 +10:30
|
|
|
(db_begin_transaction(db), __VA_ARGS__, db_commit_transaction(db), wallet_err == NULL)
|
2017-11-01 11:40:48 +10:30
|
|
|
|
2023-07-16 15:26:52 +09:30
|
|
|
struct logger *new_logger(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, const struct node_id *default_node_id UNNEEDED, const char *fmt UNNEEDED, ...)
|
2018-02-12 20:42:55 +10:30
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-18 10:57:17 +10:30
|
|
|
struct log_book *new_log_book(struct lightningd *ld UNNEEDED, size_t max_mem UNNEEDED)
|
2018-02-12 20:42:55 +10:30
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-07 10:36:07 +10:30
|
|
|
void txfilter_add_scriptpubkey(struct txfilter *filter UNNEEDED, const u8 *script TAKES)
|
|
|
|
|
{
|
|
|
|
|
if (taken(script))
|
|
|
|
|
tal_free(script);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-15 15:17:49 +09:30
|
|
|
/* Can actually be called by new_channel */
|
|
|
|
|
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-19 10:30:52 +09:30
|
|
|
void migrate_from_account_db(struct lightningd *ld UNNEEDED, struct db *db UNNEEDED)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:11:37 +01:00
|
|
|
/**
|
|
|
|
|
* mempat -- Set the memory to a pattern
|
|
|
|
|
*
|
|
|
|
|
* Used mainly to check that we don't mix fields while
|
|
|
|
|
* serializing/unserializing.
|
|
|
|
|
*/
|
|
|
|
|
static void mempat(void *dst, size_t len)
|
|
|
|
|
{
|
|
|
|
|
static int n = 0;
|
|
|
|
|
u8 *p = (u8*)dst;
|
|
|
|
|
for(int i=0 ; i < len; ++i)
|
|
|
|
|
p[i] = n % 251; /* Prime */
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 16:19:14 +02:00
|
|
|
/* Destructor for the wallet which unlinks the underlying file */
|
|
|
|
|
static void cleanup_test_wallet(struct wallet *w, char *filename)
|
|
|
|
|
{
|
|
|
|
|
unlink(filename);
|
|
|
|
|
tal_free(filename);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx)
|
2017-08-05 14:52:39 +02:00
|
|
|
{
|
2021-12-05 02:47:38 -05:00
|
|
|
char *dsn, *filename;
|
|
|
|
|
int fd = tmpdir_mkstemp(ctx, "ldb-XXXXXX", &filename);
|
2017-08-05 14:52:39 +02:00
|
|
|
struct wallet *w = tal(ctx, struct wallet);
|
2018-03-07 10:36:07 +10:30
|
|
|
static unsigned char badseed[BIP32_ENTROPY_LEN_128];
|
2020-07-28 20:20:30 -05:00
|
|
|
const struct ext_key *bip32_base = NULL;
|
2017-08-05 14:52:39 +02:00
|
|
|
CHECK_MSG(fd != -1, "Unable to generate temp filename");
|
|
|
|
|
close(fd);
|
|
|
|
|
|
2019-09-03 21:10:29 +02:00
|
|
|
dsn = tal_fmt(NULL, "sqlite3://%s", filename);
|
2025-08-19 10:30:52 +09:30
|
|
|
w->db = db_open(w, dsn, true, true, test_error, ld);
|
2022-01-03 12:45:35 -06:00
|
|
|
w->db->report_changes_fn = NULL;
|
2019-09-03 21:10:29 +02:00
|
|
|
tal_free(dsn);
|
2018-06-04 16:19:14 +02:00
|
|
|
tal_add_destructor2(w, cleanup_test_wallet, filename);
|
2017-08-05 14:52:39 +02:00
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
w->ld = ld;
|
2018-03-07 10:36:07 +10:30
|
|
|
ld->wallet = w;
|
|
|
|
|
|
2023-03-21 14:28:15 +10:30
|
|
|
ld->bip32_base = tal(ld, struct ext_key);
|
2018-03-07 10:36:07 +10:30
|
|
|
CHECK(bip32_key_from_seed(badseed, sizeof(badseed),
|
|
|
|
|
BIP32_VER_TEST_PRIVATE, 0,
|
2023-03-21 14:28:15 +10:30
|
|
|
ld->bip32_base) == WALLY_OK);
|
2017-09-26 14:43:09 +02:00
|
|
|
|
2018-01-02 14:33:42 +10:30
|
|
|
CHECK_MSG(w->db, "Failed opening the db");
|
2022-09-19 10:19:53 +09:30
|
|
|
w->db->data_version = 0;
|
2019-12-18 18:57:37 +01:00
|
|
|
db_begin_transaction(w->db);
|
2020-07-28 20:20:30 -05:00
|
|
|
db_migrate(ld, w->db, bip32_base);
|
2019-12-18 18:57:37 +01:00
|
|
|
db_commit_transaction(w->db);
|
2021-08-09 13:59:04 -05:00
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
2018-02-18 23:23:46 +10:30
|
|
|
w->max_channel_dbid = 0;
|
2018-01-02 14:33:42 +10:30
|
|
|
|
2025-08-14 12:40:11 +09:30
|
|
|
/* Create fresh channels map */
|
|
|
|
|
ld->channels_by_scid = tal(ld, struct channel_scid_map);
|
|
|
|
|
channel_scid_map_init(ld->channels_by_scid);
|
2025-08-19 10:30:45 +09:30
|
|
|
ld->channels_by_dbid = tal(ld, struct channel_dbid_map);
|
|
|
|
|
channel_dbid_map_init(ld->channels_by_dbid);
|
2017-08-05 14:52:39 +02:00
|
|
|
return w;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 16:19:14 +02:00
|
|
|
static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
|
2017-05-31 15:26:30 +02:00
|
|
|
{
|
2018-06-04 16:19:14 +02:00
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2017-05-31 15:26:30 +02:00
|
|
|
struct utxo u;
|
2017-12-20 12:44:00 +01:00
|
|
|
struct pubkey pk;
|
2019-04-08 19:28:32 +09:30
|
|
|
struct node_id id;
|
2021-08-09 13:54:00 -05:00
|
|
|
struct wireaddr_internal addr;
|
|
|
|
|
struct block block;
|
|
|
|
|
struct channel channel;
|
2020-08-28 13:26:32 +09:30
|
|
|
struct utxo *one_utxo;
|
2017-12-20 12:44:00 +01:00
|
|
|
const struct utxo **utxos;
|
2018-06-04 16:19:14 +02:00
|
|
|
CHECK(w);
|
2017-05-31 16:16:59 +02:00
|
|
|
|
2017-05-31 15:26:30 +02:00
|
|
|
memset(&u, 0, sizeof(u));
|
2019-02-21 13:09:51 +10:30
|
|
|
u.amount = AMOUNT_SAT(1);
|
2017-12-20 12:44:00 +01:00
|
|
|
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
|
2019-04-08 19:28:32 +09:30
|
|
|
node_id_from_pubkey(&id, &pk);
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
db_begin_transaction(w->db);
|
|
|
|
|
|
2017-05-31 15:26:30 +02:00
|
|
|
/* Should work, it's the first time we add it */
|
2025-05-06 05:22:46 +09:30
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
|
2017-05-31 16:16:59 +02:00
|
|
|
"wallet_add_utxo failed on first add");
|
2021-08-09 13:54:00 -05:00
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
2017-05-31 15:26:30 +02:00
|
|
|
|
|
|
|
|
/* Should fail, we already have that UTXO */
|
2025-05-06 05:22:46 +09:30
|
|
|
CHECK_MSG(!wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
|
2017-05-31 16:16:59 +02:00
|
|
|
"wallet_add_utxo succeeded on second add");
|
2021-08-09 13:54:00 -05:00
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
2017-05-31 16:16:59 +02:00
|
|
|
|
2018-02-08 22:43:01 +01:00
|
|
|
/* Attempt to save an UTXO with close_info set */
|
2021-10-13 14:15:36 +10:30
|
|
|
memset(&u.outpoint, 1, sizeof(u.outpoint));
|
2017-12-20 12:44:00 +01:00
|
|
|
u.close_info = tal(w, struct unilateral_close_info);
|
|
|
|
|
u.close_info->channel_id = 42;
|
2019-04-08 19:28:32 +09:30
|
|
|
u.close_info->peer_id = id;
|
2019-09-10 11:54:27 +09:30
|
|
|
u.close_info->commitment_point = &pk;
|
2023-06-26 08:48:21 +09:30
|
|
|
u.close_info->option_anchors = false;
|
2025-05-06 05:21:46 +09:30
|
|
|
/* P2WSH */
|
|
|
|
|
u.scriptPubkey = tal_arr(w, u8, BITCOIN_SCRIPTPUBKEY_P2WSH_LEN);
|
|
|
|
|
u.scriptPubkey[0] = OP_0;
|
|
|
|
|
u.scriptPubkey[1] = sizeof(struct sha256);
|
|
|
|
|
memset(u.scriptPubkey + 2, 1, sizeof(struct sha256));
|
2025-05-06 05:22:46 +09:30
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_OUR_CHANGE),
|
2017-12-20 12:44:00 +01:00
|
|
|
"wallet_add_utxo with close_info");
|
|
|
|
|
|
|
|
|
|
/* Now select them */
|
2020-08-28 13:26:32 +09:30
|
|
|
utxos = tal_arr(w, const struct utxo *, 0);
|
2021-08-09 13:54:00 -05:00
|
|
|
while ((one_utxo = wallet_find_utxo(w, w, 100, NULL, 253,
|
2020-08-28 13:26:32 +09:30
|
|
|
0 /* no confirmations required */,
|
2022-10-26 11:58:10 -05:00
|
|
|
false,
|
2020-08-28 13:26:32 +09:30
|
|
|
utxos)) != NULL) {
|
|
|
|
|
tal_arr_expand(&utxos, one_utxo);
|
|
|
|
|
}
|
|
|
|
|
CHECK(tal_count(utxos) == 2);
|
|
|
|
|
|
|
|
|
|
if (utxos[0]->close_info)
|
|
|
|
|
u = *utxos[0];
|
|
|
|
|
else
|
|
|
|
|
u = *utxos[1];
|
2017-12-20 12:44:00 +01:00
|
|
|
|
|
|
|
|
CHECK(u.close_info->channel_id == 42 &&
|
2019-09-10 11:54:27 +09:30
|
|
|
pubkey_eq(u.close_info->commitment_point, &pk) &&
|
2020-08-14 11:00:42 +09:30
|
|
|
node_id_eq(&u.close_info->peer_id, &id) &&
|
2023-06-26 08:48:21 +09:30
|
|
|
u.close_info->option_anchors == false);
|
2017-12-20 12:44:00 +01:00
|
|
|
|
2017-05-31 16:16:59 +02:00
|
|
|
/* Attempt to reserve the utxo */
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK_MSG(wallet_update_output_status(w, &u.outpoint,
|
2020-08-28 13:26:34 +09:30
|
|
|
OUTPUT_STATE_AVAILABLE,
|
|
|
|
|
OUTPUT_STATE_RESERVED),
|
2017-05-31 16:16:59 +02:00
|
|
|
"could not reserve available output");
|
|
|
|
|
|
|
|
|
|
/* Reserving twice should fail */
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK_MSG(!wallet_update_output_status(w, &u.outpoint,
|
2020-08-28 13:26:34 +09:30
|
|
|
OUTPUT_STATE_AVAILABLE,
|
|
|
|
|
OUTPUT_STATE_RESERVED),
|
2017-05-31 16:16:59 +02:00
|
|
|
"could reserve already reserved output");
|
|
|
|
|
|
|
|
|
|
/* Un-reserving should work */
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK_MSG(wallet_update_output_status(w, &u.outpoint,
|
2020-08-28 13:26:34 +09:30
|
|
|
OUTPUT_STATE_RESERVED,
|
|
|
|
|
OUTPUT_STATE_AVAILABLE),
|
2017-05-31 16:16:59 +02:00
|
|
|
"could not unreserve reserved output");
|
|
|
|
|
|
|
|
|
|
/* Switching from any to something else */
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK_MSG(wallet_update_output_status(w, &u.outpoint,
|
2020-08-28 13:26:34 +09:30
|
|
|
OUTPUT_STATE_ANY,
|
|
|
|
|
OUTPUT_STATE_SPENT),
|
2017-05-31 16:16:59 +02:00
|
|
|
"could not change output state ignoring oldstate");
|
|
|
|
|
|
2019-09-10 11:54:27 +09:30
|
|
|
/* Attempt to save an UTXO with close_info set, no commitment_point */
|
2021-10-13 14:15:36 +10:30
|
|
|
memset(&u.outpoint, 2, sizeof(u.outpoint));
|
2019-09-10 11:54:27 +09:30
|
|
|
u.amount = AMOUNT_SAT(5);
|
|
|
|
|
u.close_info = tal(w, struct unilateral_close_info);
|
|
|
|
|
u.close_info->channel_id = 42;
|
|
|
|
|
u.close_info->peer_id = id;
|
|
|
|
|
u.close_info->commitment_point = NULL;
|
2023-06-26 08:48:21 +09:30
|
|
|
u.close_info->option_anchors = true;
|
2021-08-09 13:54:00 -05:00
|
|
|
/* The blockheight has to be set for an option_anchor_output
|
|
|
|
|
* closed UTXO to be spendable */
|
|
|
|
|
u32 *blockheight = tal(w, u32);
|
|
|
|
|
*blockheight = 100;
|
|
|
|
|
/* We gotta add a block to the database though */
|
wallet-test: fix segfault due to uninitialized block
The variable `block` (instace of `struct block`) is
allocated on the stack without being initialized, i.e. its
member `prev` points to nowhere. This causes a segmentation
fault on my machine on the binding of "prev_hash" on running
`wallet_block_add`, as the following core-dump analysis
shows:
$ egdb ./wallet/test/run-wallet ./run-wallet.core
[...]
Core was generated by `run-wallet'.
Program terminated with signal SIGSEGV, Segmentation fault.
---Type <return> to continue, or q <return> to quit---
#0 0x000008f67a04b660 in memcpy (dst0=<optimized out>, src0=0x100007f8c, length=32) at /usr/src/lib/libc/string/memcpy.c:97
97 TLOOP1(*dst++ = *src++);
(gdb) bt
#0 0x000008f67a04b660 in memcpy (dst0=<optimized out>, src0=0x100007f8c, length=32) at /usr/src/lib/libc/string/memcpy.c:97
#1 0x000008f73e838f60 in sqlite3VdbeMemSetStr () from /usr/local/lib/libsqlite3.so.37.12
#2 0x000008f73e83cb11 in bindText () from /usr/local/lib/libsqlite3.so.37.12
#3 0x000008f44bc91345 in db_sqlite3_query (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:77
#4 0x000008f44bc91122 in db_sqlite3_exec (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:110
#5 0x000008f44bcbb3b2 in db_exec_prepared_v2 (stmt=0x8f6845bf028) at ./wallet/db.c:2055
#6 0x000008f44bcc6890 in wallet_block_add (w=0x8f688b5bba8, b=0x7f7ffffca788) at ./wallet/wallet.c:3556
#7 0x000008f44bce2607 in test_wallet_outputs (ld=0x8f6a35a7828, ctx=0x8f6a35c0268) at wallet/test/run-wallet.c:1104
#8 0x000008f44bcddec0 in main (argc=1, argv=0x7f7ffffcaaf8) at wallet/test/run-wallet.c:1930
Fix by explicitely setting the whole structure to zero.
[ Rebuilt generated files, too --RR ]
2021-08-22 14:31:35 +02:00
|
|
|
memset(&block, 0, sizeof(block));
|
2021-08-09 13:54:00 -05:00
|
|
|
block.height = 100;
|
|
|
|
|
memset(&block.blkid, 2, sizeof(block.blkid));
|
|
|
|
|
wallet_block_add(w, &block);
|
|
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
|
|
|
|
|
|
|
|
|
u.blockheight = blockheight;
|
2025-05-06 05:21:46 +09:30
|
|
|
u.scriptPubkey = tal_arr(w, u8, BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN);
|
|
|
|
|
u.scriptPubkey[0] = OP_0;
|
|
|
|
|
u.scriptPubkey[1] = sizeof(struct ripemd160);
|
|
|
|
|
memset(u.scriptPubkey + 2, 1, sizeof(struct ripemd160));
|
2025-05-06 05:22:46 +09:30
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
|
2019-09-10 11:54:27 +09:30
|
|
|
"wallet_add_utxo with close_info no commitment_point");
|
2021-08-09 13:54:00 -05:00
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
2019-09-10 11:54:27 +09:30
|
|
|
|
2021-08-09 13:54:00 -05:00
|
|
|
/* Add another utxo that's CSV-locked for 5 blocks */
|
2023-05-30 13:58:18 +09:30
|
|
|
assert(parse_wireaddr_internal(tmpctx, "localhost:1234", 0, false, &addr) == NULL);
|
2024-11-24 12:09:16 +10:30
|
|
|
channel.peer = new_peer(ld, 0, &id, &addr, NULL, NULL, false);
|
2021-08-09 13:54:00 -05:00
|
|
|
channel.dbid = 1;
|
2024-06-19 09:31:01 +09:30
|
|
|
channel.type = channel_type_anchors_zero_fee_htlc(tmpctx);
|
2021-10-13 14:15:36 +10:30
|
|
|
memset(&u.outpoint, 3, sizeof(u.outpoint));
|
|
|
|
|
CHECK_MSG(wallet_add_onchaind_utxo(w, &u.outpoint,
|
2021-08-09 13:54:00 -05:00
|
|
|
u.scriptPubkey,
|
|
|
|
|
*u.blockheight,
|
|
|
|
|
AMOUNT_SAT(3),
|
|
|
|
|
&channel,
|
|
|
|
|
NULL,
|
|
|
|
|
5),
|
|
|
|
|
"wallet_add_utxo with close_info and csv > 1");
|
|
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
2021-11-15 04:22:46 +10:30
|
|
|
/* Normally freed by destroy_channel, but we don't call that */
|
|
|
|
|
tal_free(channel.peer);
|
2021-08-09 13:54:00 -05:00
|
|
|
|
|
|
|
|
/* Select everything but 5 csv-locked utxo */
|
2020-08-28 13:26:32 +09:30
|
|
|
utxos = tal_arr(w, const struct utxo *, 0);
|
2021-08-09 13:54:00 -05:00
|
|
|
while ((one_utxo = wallet_find_utxo(w, w, 100, NULL, 253,
|
2020-08-28 13:26:32 +09:30
|
|
|
0 /* no confirmations required */,
|
2022-10-26 11:58:10 -05:00
|
|
|
false,
|
2020-08-28 13:26:32 +09:30
|
|
|
utxos)) != NULL) {
|
|
|
|
|
tal_arr_expand(&utxos, one_utxo);
|
|
|
|
|
}
|
|
|
|
|
CHECK(tal_count(utxos) == 2);
|
|
|
|
|
if (utxos[0]->close_info)
|
|
|
|
|
u = *utxos[0];
|
|
|
|
|
else
|
|
|
|
|
u = *utxos[1];
|
2019-09-10 11:54:27 +09:30
|
|
|
|
|
|
|
|
CHECK(u.close_info->channel_id == 42 &&
|
|
|
|
|
u.close_info->commitment_point == NULL &&
|
2020-08-14 11:00:42 +09:30
|
|
|
node_id_eq(&u.close_info->peer_id, &id) &&
|
2023-06-26 08:48:21 +09:30
|
|
|
u.close_info->option_anchors == true &&
|
2021-08-09 13:54:00 -05:00
|
|
|
u.close_info->csv == 1);
|
|
|
|
|
/* Now un-reserve them */
|
|
|
|
|
tal_free(utxos);
|
|
|
|
|
|
|
|
|
|
/* Select all utxos (5 csv-locked included) */
|
|
|
|
|
utxos = tal_arr(w, const struct utxo *, 0);
|
|
|
|
|
while ((one_utxo = wallet_find_utxo(w, w, 104, NULL, 253,
|
|
|
|
|
0 /* no confirmations required */,
|
2022-10-26 11:58:10 -05:00
|
|
|
false,
|
2021-08-09 13:54:00 -05:00
|
|
|
utxos)) != NULL) {
|
|
|
|
|
tal_arr_expand(&utxos, one_utxo);
|
|
|
|
|
}
|
|
|
|
|
CHECK(tal_count(utxos) == 3);
|
|
|
|
|
for (size_t i = 0; i < tal_count(utxos); i++) {
|
|
|
|
|
if (!utxos[i]->close_info)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
CHECK(u.close_info->channel_id == 42 &&
|
|
|
|
|
u.close_info->commitment_point == NULL &&
|
|
|
|
|
node_id_eq(&u.close_info->peer_id, &id) &&
|
2023-06-26 08:48:21 +09:30
|
|
|
u.close_info->option_anchors == true &&
|
2021-08-09 13:54:00 -05:00
|
|
|
u.close_info->csv > 0);
|
|
|
|
|
}
|
2019-09-10 11:54:27 +09:30
|
|
|
/* Now un-reserve them */
|
|
|
|
|
tal_free(utxos);
|
|
|
|
|
|
2022-10-26 11:58:10 -05:00
|
|
|
/* Check that nonwrapped flag works */
|
|
|
|
|
utxos = tal_arr(w, const struct utxo *, 0);
|
|
|
|
|
while ((one_utxo = wallet_find_utxo(w, w, 100, NULL, 253,
|
|
|
|
|
0 /* no confirmations required */,
|
|
|
|
|
true,
|
|
|
|
|
utxos)) != NULL) {
|
|
|
|
|
tal_arr_expand(&utxos, one_utxo);
|
|
|
|
|
}
|
|
|
|
|
/* No nonwrapped outputs available */
|
|
|
|
|
CHECK(tal_count(utxos) == 0);
|
|
|
|
|
tal_free(utxos);
|
|
|
|
|
|
|
|
|
|
/* So we add one... */
|
|
|
|
|
memset(&u.outpoint, 4, sizeof(u.outpoint));
|
|
|
|
|
u.amount = AMOUNT_SAT(4);
|
|
|
|
|
u.close_info = tal_free(u.close_info);
|
2025-05-06 05:22:46 +09:30
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2WPKH),
|
2022-10-26 11:58:10 -05:00
|
|
|
"wallet_add_utxo failed, p2wpkh");
|
|
|
|
|
|
|
|
|
|
utxos = tal_arr(w, const struct utxo *, 0);
|
|
|
|
|
while ((one_utxo = wallet_find_utxo(w, w, 100, NULL, 253,
|
|
|
|
|
0 /* no confirmations required */,
|
|
|
|
|
true,
|
|
|
|
|
utxos)) != NULL) {
|
|
|
|
|
tal_arr_expand(&utxos, one_utxo);
|
|
|
|
|
}
|
|
|
|
|
/* And that's what comes back */
|
|
|
|
|
CHECK(tal_count(utxos) == 1);
|
|
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
db_commit_transaction(w->db);
|
2017-05-31 15:26:30 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 16:19:14 +02:00
|
|
|
static bool test_shachain_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-07-18 19:03:05 +02:00
|
|
|
{
|
|
|
|
|
struct wallet_shachain a, b;
|
2018-06-04 16:19:14 +02:00
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2017-07-18 19:03:05 +02:00
|
|
|
struct sha256 seed, hash;
|
2018-07-09 20:47:58 +09:30
|
|
|
struct secret secret;
|
2017-08-18 14:13:53 +09:30
|
|
|
uint64_t index = UINT64_MAX >> (64 - SHACHAIN_BITS);
|
2017-07-18 19:03:05 +02:00
|
|
|
|
|
|
|
|
memset(&seed, 'A', sizeof(seed));
|
|
|
|
|
memset(&a, 0, sizeof(a));
|
|
|
|
|
memset(&b, 0, sizeof(b));
|
|
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
db_begin_transaction(w->db);
|
|
|
|
|
CHECK_MSG(!wallet_err, "db_begin_transaction failed");
|
|
|
|
|
wallet_shachain_init(w, &a);
|
|
|
|
|
CHECK(!wallet_err);
|
2017-07-18 19:03:05 +02:00
|
|
|
|
|
|
|
|
CHECK(a.id == 1);
|
|
|
|
|
|
2017-08-18 14:13:53 +09:30
|
|
|
CHECK(a.chain.num_valid == 0);
|
|
|
|
|
CHECK(shachain_next_index(&a.chain) == index);
|
2017-07-18 19:03:05 +02:00
|
|
|
|
|
|
|
|
for (int i=0; i<100; i++) {
|
|
|
|
|
shachain_from_seed(&seed, index, &hash);
|
2018-07-09 20:47:58 +09:30
|
|
|
memcpy(&secret, &hash, sizeof(secret));
|
|
|
|
|
CHECK(wallet_shachain_add_hash(w, &a, index, &secret));
|
2017-07-18 19:03:05 +02:00
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CHECK(wallet_shachain_load(w, a.id, &b));
|
|
|
|
|
CHECK_MSG(memcmp(&a, &b, sizeof(a)) == 0, "Loading from database doesn't match");
|
2017-11-01 11:51:56 +10:30
|
|
|
|
|
|
|
|
db_commit_transaction(w->db);
|
|
|
|
|
CHECK(!wallet_err);
|
2017-07-18 19:03:05 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-18 14:13:52 +09:30
|
|
|
static bool bitcoin_tx_eq(const struct bitcoin_tx *tx1,
|
|
|
|
|
const struct bitcoin_tx *tx2)
|
|
|
|
|
{
|
|
|
|
|
u8 *lin1, *lin2;
|
|
|
|
|
bool eq;
|
|
|
|
|
lin1 = linearize_tx(NULL, tx1);
|
|
|
|
|
lin2 = linearize_tx(lin1, tx2);
|
2024-02-14 20:08:33 +10:30
|
|
|
eq = tal_arr_eq(lin1, lin2);
|
2017-08-18 14:13:52 +09:30
|
|
|
tal_free(lin1);
|
|
|
|
|
return eq;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
static bool channel_inflightseq(struct channel_inflight *i1,
|
|
|
|
|
struct channel_inflight *i2)
|
|
|
|
|
{
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK(memeq(&i1->funding->outpoint.txid,
|
2021-02-04 15:14:44 -06:00
|
|
|
sizeof(struct sha256_double),
|
2021-10-13 14:15:36 +10:30
|
|
|
&i2->funding->outpoint.txid,
|
2021-02-04 15:14:44 -06:00
|
|
|
sizeof(struct sha256_double)));
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK(i1->funding->outpoint.n == i2->funding->outpoint.n);
|
2021-02-04 15:14:44 -06:00
|
|
|
CHECK(i1->funding->feerate == i2->funding->feerate);
|
|
|
|
|
CHECK(amount_sat_eq(i1->funding->total_funds,
|
|
|
|
|
i2->funding->total_funds));
|
|
|
|
|
CHECK(amount_sat_eq(i1->funding->our_funds, i2->funding->our_funds));
|
|
|
|
|
CHECK(memeq(&i1->last_sig, sizeof(i1->last_sig),
|
|
|
|
|
&i2->last_sig, sizeof(i2->last_sig)));
|
|
|
|
|
CHECK(bitcoin_tx_eq(i1->last_tx, i2->last_tx));
|
|
|
|
|
|
2022-10-24 13:12:36 -05:00
|
|
|
CHECK(amount_sat_eq(i1->lease_amt, i2->lease_amt));
|
2021-06-22 13:25:59 -05:00
|
|
|
CHECK(!i1->lease_commit_sig == !i2->lease_commit_sig);
|
|
|
|
|
if (i1->lease_commit_sig)
|
|
|
|
|
CHECK(memeq(i1->lease_commit_sig, sizeof(*i1->lease_commit_sig),
|
|
|
|
|
i2->lease_commit_sig, sizeof(*i2->lease_commit_sig)));
|
|
|
|
|
CHECK(i1->lease_expiry == i2->lease_expiry);
|
|
|
|
|
CHECK(i1->lease_chan_max_msat == i2->lease_chan_max_msat);
|
|
|
|
|
CHECK(i1->lease_chan_max_ppt == i2->lease_chan_max_ppt);
|
|
|
|
|
CHECK(i1->lease_blockheight_start == i2->lease_blockheight_start);
|
2025-02-01 10:41:33 -05:00
|
|
|
CHECK(!i1->locked_scid == !i2->locked_scid);
|
|
|
|
|
if (i1->locked_scid)
|
|
|
|
|
CHECK(memeq(i1->locked_scid, sizeof(*i1->locked_scid),
|
|
|
|
|
i2->locked_scid, sizeof(*i2->locked_scid)));
|
|
|
|
|
CHECK(i1->splice_locked_memonly == i2->splice_locked_memonly);
|
2021-06-22 13:25:59 -05:00
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static bool channelseq(struct channel *c1, struct channel *c2)
|
2017-08-05 12:28:44 +02:00
|
|
|
{
|
|
|
|
|
struct peer *p1 = c1->peer, *p2 = c2->peer;
|
2018-02-19 11:36:12 +10:30
|
|
|
struct channel_info *ci1 = &c1->channel_info, *ci2 = &c2->channel_info;
|
2018-02-12 20:42:55 +10:30
|
|
|
struct changed_htlc *lc1 = c1->last_sent_commit, *lc2 = c2->last_sent_commit;
|
2021-02-04 15:14:44 -06:00
|
|
|
struct channel_inflight *i1, *i2;
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1->dbid == c2->dbid);
|
2018-02-06 12:15:26 +01:00
|
|
|
CHECK(c1->first_blocknum == c2->first_blocknum);
|
2017-08-14 22:06:59 +02:00
|
|
|
CHECK(c1->peer->dbid == c2->peer->dbid);
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1->peer == c2->peer);
|
|
|
|
|
CHECK(c1->their_shachain.id == c2->their_shachain.id);
|
2019-04-08 19:28:32 +09:30
|
|
|
CHECK_MSG(node_id_eq(&p1->id, &p2->id), "NodeIDs do not match");
|
2018-07-04 15:00:02 +09:30
|
|
|
CHECK((c1->scid == NULL && c2->scid == NULL)
|
2024-03-20 12:29:51 +10:30
|
|
|
|| short_channel_id_eq(*c1->scid, *c2->scid));
|
2019-02-21 14:15:55 +10:30
|
|
|
CHECK(amount_msat_eq(c1->our_msat, c2->our_msat));
|
2024-02-14 20:08:33 +10:30
|
|
|
CHECK((c1->shutdown_scriptpubkey[REMOTE] == NULL && c2->shutdown_scriptpubkey[REMOTE] == NULL) || tal_arr_eq(
|
2019-09-29 15:35:45 +08:00
|
|
|
c1->shutdown_scriptpubkey[REMOTE],
|
2024-02-14 20:08:33 +10:30
|
|
|
c2->shutdown_scriptpubkey[REMOTE]));
|
2021-10-13 14:15:36 +10:30
|
|
|
CHECK(bitcoin_outpoint_eq(&c1->funding, &c2->funding));
|
2018-02-19 11:36:12 +10:30
|
|
|
CHECK(pubkey_eq(&ci1->remote_fundingkey, &ci2->remote_fundingkey));
|
|
|
|
|
CHECK(pubkey_eq(&ci1->theirbase.revocation, &ci2->theirbase.revocation));
|
|
|
|
|
CHECK(pubkey_eq(&ci1->theirbase.payment, &ci2->theirbase.payment));
|
|
|
|
|
CHECK(pubkey_eq(&ci1->theirbase.delayed_payment, &ci2->theirbase.delayed_payment));
|
|
|
|
|
CHECK(pubkey_eq(&ci1->remote_per_commit, &ci2->remote_per_commit));
|
|
|
|
|
CHECK(pubkey_eq(&ci1->old_remote_per_commit, &ci2->old_remote_per_commit));
|
|
|
|
|
CHECK(ci1->their_config.id != 0 && ci1->their_config.id == ci2->their_config.id);
|
2020-09-17 11:28:59 +09:30
|
|
|
CHECK(fee_states_valid(c1->fee_states, c1->opener));
|
|
|
|
|
CHECK(fee_states_valid(c2->fee_states, c2->opener));
|
|
|
|
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(c1->fee_states->feerate);
|
2019-12-13 03:48:25 +10:30
|
|
|
i++) {
|
2020-09-17 11:28:59 +09:30
|
|
|
if (c1->fee_states->feerate[i] == NULL) {
|
|
|
|
|
CHECK(c2->fee_states->feerate[i] == NULL);
|
2019-12-13 03:48:25 +10:30
|
|
|
} else {
|
2020-09-17 11:28:59 +09:30
|
|
|
CHECK(*c1->fee_states->feerate[i]
|
|
|
|
|
== *c2->fee_states->feerate[i]);
|
2019-12-13 03:48:25 +10:30
|
|
|
}
|
|
|
|
|
}
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1->our_config.id != 0 && c1->our_config.id == c2->our_config.id);
|
2017-08-05 12:28:44 +02:00
|
|
|
CHECK((lc1 != NULL) == (lc2 != NULL));
|
2018-09-04 16:32:35 +09:30
|
|
|
CHECK(tal_count(lc1) == tal_count(lc2));
|
|
|
|
|
for (size_t i = 0; i < tal_count(lc1); i++) {
|
|
|
|
|
CHECK(lc1[i].newstate == lc2[i].newstate);
|
|
|
|
|
CHECK(lc1[i].id == lc2[i].id);
|
2017-08-05 12:28:44 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK((c1->last_tx != NULL) == (c2->last_tx != NULL));
|
2020-01-05 16:52:34 +01:00
|
|
|
if (c1->last_tx) {
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(bitcoin_tx_eq(c1->last_tx, c2->last_tx));
|
2017-08-18 14:13:52 +09:30
|
|
|
}
|
2018-02-19 11:36:12 +10:30
|
|
|
CHECK(memeq(&c1->last_sig, sizeof(c1->last_sig),
|
|
|
|
|
&c2->last_sig, sizeof(c2->last_sig)));
|
2017-08-18 14:13:52 +09:30
|
|
|
|
2018-03-07 10:36:07 +10:30
|
|
|
CHECK(c1->final_key_idx == c2->final_key_idx);
|
2024-02-14 20:08:33 +10:30
|
|
|
CHECK(tal_arr_eq(c1->shutdown_scriptpubkey[REMOTE],
|
|
|
|
|
c2->shutdown_scriptpubkey[REMOTE]));
|
2017-11-26 00:06:33 +01:00
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1->last_was_revoke == c2->last_was_revoke);
|
2018-01-13 14:25:49 +01:00
|
|
|
|
2021-06-22 13:25:59 -05:00
|
|
|
CHECK(!c1->lease_commit_sig == !c2->lease_commit_sig);
|
|
|
|
|
if (c1->lease_commit_sig)
|
|
|
|
|
CHECK(memeq(c1->lease_commit_sig, sizeof(*c1->lease_commit_sig),
|
|
|
|
|
c2->lease_commit_sig, sizeof(*c2->lease_commit_sig)));
|
|
|
|
|
|
|
|
|
|
CHECK(c1->lease_chan_max_msat == c2->lease_chan_max_msat);
|
|
|
|
|
CHECK(c1->lease_chan_max_ppt == c2->lease_chan_max_ppt);
|
|
|
|
|
CHECK(c1->lease_expiry == c2->lease_expiry);
|
|
|
|
|
|
|
|
|
|
CHECK(height_states_valid(c1->blockheight_states, c1->opener));
|
|
|
|
|
CHECK(height_states_valid(c2->blockheight_states, c2->opener));
|
|
|
|
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(c1->blockheight_states->height);
|
|
|
|
|
i++) {
|
|
|
|
|
if (c1->blockheight_states->height[i] == NULL) {
|
|
|
|
|
CHECK(c2->blockheight_states->height[i] == NULL);
|
|
|
|
|
} else {
|
|
|
|
|
CHECK(*c1->blockheight_states->height[i]
|
|
|
|
|
== *c2->blockheight_states->height[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
i1 = list_top(&c1->inflights, struct channel_inflight, list);
|
|
|
|
|
i2 = list_top(&c2->inflights, struct channel_inflight, list);
|
|
|
|
|
CHECK((i1 != NULL) == (i2 != NULL));
|
|
|
|
|
if (!i1 && !i2)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
while ((i1 = list_next(&c1->inflights, i1, list))) {
|
|
|
|
|
i2 = list_next(&c2->inflights, i2, list);
|
|
|
|
|
CHECK(i2 != NULL);
|
|
|
|
|
CHECK(channel_inflightseq(i1, i2));
|
|
|
|
|
}
|
|
|
|
|
/* c2 should also be out of inflights */
|
|
|
|
|
CHECK(list_next(&c2->inflights, i2, list) == NULL);
|
2021-09-09 14:59:35 +09:30
|
|
|
CHECK(channel_type_eq(c1->type, c2->type));
|
2021-02-04 15:14:44 -06:00
|
|
|
|
2017-08-05 12:28:44 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static struct channel *wallet_channel_load(struct wallet *w, const u64 dbid)
|
2018-01-03 15:55:30 +10:30
|
|
|
{
|
|
|
|
|
struct peer *peer;
|
2018-02-12 20:42:55 +10:30
|
|
|
struct channel *channel;
|
2023-01-18 15:34:32 +10:30
|
|
|
struct peer_node_id_map_iter it;
|
2018-01-03 15:55:30 +10:30
|
|
|
|
|
|
|
|
/* We expect only one peer, but reuse same code */
|
2019-08-09 11:01:31 -05:00
|
|
|
if (!wallet_init_channels(w))
|
2018-01-03 15:55:30 +10:30
|
|
|
return NULL;
|
2023-01-18 15:34:32 +10:30
|
|
|
peer = peer_node_id_map_first(w->ld->peers, &it);
|
2018-01-03 15:55:30 +10:30
|
|
|
CHECK(peer);
|
2018-02-12 20:42:55 +10:30
|
|
|
|
|
|
|
|
/* We load lots of identical dbid channels: use last one */
|
|
|
|
|
channel = list_tail(&peer->channels, struct channel, list);
|
|
|
|
|
assert(channel->dbid == dbid);
|
|
|
|
|
return channel;
|
2018-01-03 15:55:30 +10:30
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-08-05 12:28:44 +02:00
|
|
|
{
|
2018-02-12 20:42:55 +10:30
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
|
|
|
|
struct channel c1, *c2 = tal(w, struct channel);
|
2018-10-26 16:31:26 +10:30
|
|
|
struct wireaddr_internal addr;
|
2018-02-12 20:42:55 +10:30
|
|
|
struct peer *p;
|
2018-02-19 11:36:12 +10:30
|
|
|
struct channel_info *ci = &c1.channel_info;
|
2017-12-18 17:11:52 +10:30
|
|
|
struct bitcoin_txid *hash = tal(w, struct bitcoin_txid);
|
2017-08-05 12:28:44 +02:00
|
|
|
struct pubkey pk;
|
2019-04-08 19:28:32 +09:30
|
|
|
struct node_id id;
|
2018-09-04 16:32:35 +09:30
|
|
|
struct changed_htlc *last_commit;
|
2025-08-14 12:40:11 +09:30
|
|
|
struct short_channel_id local_alias;
|
2017-08-08 19:09:08 +02:00
|
|
|
secp256k1_ecdsa_signature *sig = tal(w, secp256k1_ecdsa_signature);
|
2017-11-26 00:06:33 +01:00
|
|
|
u8 *scriptpubkey = tal_arr(ctx, u8, 100);
|
2019-05-02 02:17:31 +08:00
|
|
|
secp256k1_ecdsa_signature *node_sig1 = tal(w, secp256k1_ecdsa_signature);
|
|
|
|
|
secp256k1_ecdsa_signature *bitcoin_sig1 = tal(w, secp256k1_ecdsa_signature);
|
|
|
|
|
secp256k1_ecdsa_signature *node_sig2, *bitcoin_sig2;
|
2021-06-22 13:25:59 -05:00
|
|
|
u32 feerate, blockheight;
|
2019-05-02 02:17:31 +08:00
|
|
|
bool load;
|
2021-09-09 14:59:35 +09:30
|
|
|
const struct channel_type *type = channel_type_static_remotekey(w);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
|
memset(&c1, 0, sizeof(c1));
|
|
|
|
|
memset(c2, 0, sizeof(*c2));
|
2018-02-19 11:36:12 +10:30
|
|
|
memset(ci, 3, sizeof(*ci));
|
2017-10-31 00:11:37 +01:00
|
|
|
mempat(hash, sizeof(*hash));
|
|
|
|
|
mempat(sig, sizeof(*sig));
|
2019-05-02 02:17:31 +08:00
|
|
|
mempat(node_sig1, sizeof(*node_sig1));
|
|
|
|
|
mempat(bitcoin_sig1, sizeof(*bitcoin_sig1));
|
2018-09-04 16:32:35 +09:30
|
|
|
last_commit = tal_arr(w, struct changed_htlc, 2);
|
|
|
|
|
mempat(last_commit, tal_bytelen(last_commit));
|
2017-08-05 12:28:44 +02:00
|
|
|
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
|
2019-04-08 19:28:32 +09:30
|
|
|
node_id_from_pubkey(&id, &pk);
|
2019-12-13 03:48:25 +10:30
|
|
|
feerate = 31337;
|
2020-09-17 11:28:59 +09:30
|
|
|
c1.fee_states = new_fee_states(w, c1.opener, &feerate);
|
2021-06-22 13:25:59 -05:00
|
|
|
blockheight = 10010;
|
|
|
|
|
c1.blockheight_states = new_height_states(w, c1.opener, &blockheight);
|
2018-07-28 15:30:16 +09:30
|
|
|
mempat(scriptpubkey, tal_count(scriptpubkey));
|
2018-02-06 12:15:26 +01:00
|
|
|
c1.first_blocknum = 1;
|
2023-05-30 13:58:18 +09:30
|
|
|
assert(parse_wireaddr_internal(tmpctx, "localhost:1234", 0, false, &addr) == NULL);
|
2018-03-07 10:36:07 +10:30
|
|
|
c1.final_key_idx = 1337;
|
2024-11-24 12:09:16 +10:30
|
|
|
p = new_peer(ld, 0, &id, &addr, NULL, NULL, false);
|
2018-02-12 20:42:55 +10:30
|
|
|
c1.peer = p;
|
2018-02-18 23:23:46 +10:30
|
|
|
c1.dbid = wallet_get_channel_dbid(w);
|
2018-02-12 20:42:55 +10:30
|
|
|
c1.state = CHANNELD_NORMAL;
|
2018-02-19 11:36:12 +10:30
|
|
|
memset(&ci->their_config, 0, sizeof(struct channel_config));
|
|
|
|
|
ci->remote_fundingkey = pk;
|
|
|
|
|
ci->theirbase.revocation = pk;
|
|
|
|
|
ci->theirbase.payment = pk;
|
|
|
|
|
ci->theirbase.htlc = pk;
|
|
|
|
|
ci->theirbase.delayed_payment = pk;
|
2021-03-01 20:45:39 +01:00
|
|
|
|
|
|
|
|
c1.local_basepoints.revocation = pk;
|
|
|
|
|
c1.local_basepoints.payment = pk;
|
|
|
|
|
c1.local_basepoints.htlc = pk;
|
|
|
|
|
c1.local_basepoints.delayed_payment = pk;
|
|
|
|
|
c1.local_funding_pubkey = pk;
|
|
|
|
|
|
2018-02-19 11:36:12 +10:30
|
|
|
ci->remote_per_commit = pk;
|
|
|
|
|
ci->old_remote_per_commit = pk;
|
|
|
|
|
/* last_tx taken from BOLT #3 */
|
|
|
|
|
c1.last_tx = bitcoin_tx_from_hex(w, "02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220", strlen("02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220"));
|
2018-12-03 09:45:06 +10:30
|
|
|
c1.last_sig.s = *sig;
|
|
|
|
|
c1.last_sig.sighash_type = SIGHASH_ALL;
|
2019-07-30 22:04:55 +02:00
|
|
|
c1.last_tx->chainparams = chainparams_for_network("bitcoin");
|
2021-01-19 19:09:38 -06:00
|
|
|
c1.unsaved_dbid = 0;
|
2021-02-04 15:14:44 -06:00
|
|
|
/* Init channel inflights */
|
|
|
|
|
list_head_init(&c1.inflights);
|
2021-09-09 14:59:35 +09:30
|
|
|
c1.type = type;
|
2025-08-14 12:40:11 +09:30
|
|
|
local_alias = random_scid();
|
|
|
|
|
c1.alias[LOCAL] = &local_alias;
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
db_begin_transaction(w->db);
|
|
|
|
|
CHECK(!wallet_err);
|
|
|
|
|
|
2018-02-18 23:23:46 +10:30
|
|
|
wallet_channel_insert(w, &c1);
|
|
|
|
|
|
2018-02-19 11:36:12 +10:30
|
|
|
/* Variant 1: insert with null for scid, last_sent_commit */
|
2018-02-06 12:15:26 +01:00
|
|
|
wallet_channel_save(w, &c1);
|
2017-11-01 11:40:48 +10:30
|
|
|
CHECK_MSG(!wallet_err,
|
2017-11-01 11:51:56 +10:30
|
|
|
tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK_MSG(!wallet_err,
|
|
|
|
|
tal_fmt(w, "Load from DB: %s", wallet_err));
|
2017-08-05 12:28:44 +02:00
|
|
|
CHECK_MSG(channelseq(&c1, c2), "Compare loaded with saved (v1)");
|
2018-02-14 12:23:04 +10:30
|
|
|
tal_free(c2);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
|
/* We just inserted them into an empty DB so this must be 1 */
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1.dbid == 1);
|
2017-08-14 22:06:59 +02:00
|
|
|
CHECK(c1.peer->dbid == 1);
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1.their_shachain.id == 1);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
|
/* Variant 2: update with scid set */
|
2018-02-12 20:42:55 +10:30
|
|
|
c1.scid = talz(w, struct short_channel_id);
|
2018-02-19 11:36:12 +10:30
|
|
|
c1.last_was_revoke = !c1.last_was_revoke;
|
2018-02-06 12:15:26 +01:00
|
|
|
wallet_channel_save(w, &c1);
|
2017-11-01 11:40:48 +10:30
|
|
|
CHECK_MSG(!wallet_err,
|
2017-11-01 11:51:56 +10:30
|
|
|
tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK_MSG(!wallet_err,
|
2019-05-03 02:28:33 +08:00
|
|
|
tal_fmt(w, "Load from DB: %s", wallet_err));
|
2017-08-05 12:28:44 +02:00
|
|
|
CHECK_MSG(channelseq(&c1, c2), "Compare loaded with saved (v2)");
|
2018-02-14 12:23:04 +10:30
|
|
|
tal_free(c2);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
|
/* Updates should not result in new ids */
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1.dbid == 1);
|
2017-08-14 22:06:59 +02:00
|
|
|
CHECK(c1.peer->dbid == 1);
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK(c1.their_shachain.id == 1);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2018-02-19 11:36:12 +10:30
|
|
|
/* Variant 3: update with last_commit_sent */
|
2018-09-04 16:32:35 +09:30
|
|
|
c1.last_sent_commit = last_commit;
|
2018-02-06 12:15:26 +01:00
|
|
|
wallet_channel_save(w, &c1);
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK_MSG(!wallet_err, tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK_MSG(!wallet_err,
|
2019-05-03 02:28:33 +08:00
|
|
|
tal_fmt(w, "Load from DB: %s", wallet_err));
|
2019-05-03 02:31:16 +08:00
|
|
|
CHECK_MSG(channelseq(&c1, c2), "Compare loaded with saved (v3)");
|
2018-02-14 12:23:04 +10:30
|
|
|
tal_free(c2);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2019-05-02 02:17:31 +08:00
|
|
|
/* Updates should not result in new ids */
|
|
|
|
|
CHECK(c1.dbid == 1);
|
|
|
|
|
CHECK(c1.peer->dbid == 1);
|
|
|
|
|
CHECK(c1.their_shachain.id == 1);
|
|
|
|
|
|
2019-09-29 15:35:45 +08:00
|
|
|
/* Variant 4: update and add shutdown_scriptpubkey[REMOTE] */
|
|
|
|
|
c1.shutdown_scriptpubkey[REMOTE] = scriptpubkey;
|
2018-02-06 12:15:26 +01:00
|
|
|
wallet_channel_save(w, &c1);
|
2017-11-26 00:06:33 +01:00
|
|
|
CHECK_MSG(!wallet_err, tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 20:42:55 +10:30
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-26 00:06:33 +01:00
|
|
|
CHECK_MSG(!wallet_err,
|
2019-05-03 02:28:33 +08:00
|
|
|
tal_fmt(w, "Load from DB: %s", wallet_err));
|
2019-05-03 02:31:16 +08:00
|
|
|
CHECK_MSG(channelseq(&c1, c2), "Compare loaded with saved (v4)");
|
2018-02-14 12:23:04 +10:30
|
|
|
tal_free(c2);
|
2017-11-26 00:06:33 +01:00
|
|
|
|
2019-05-02 02:17:31 +08:00
|
|
|
/* Updates should not result in new ids */
|
|
|
|
|
CHECK(c1.dbid == 1);
|
|
|
|
|
CHECK(c1.peer->dbid == 1);
|
|
|
|
|
CHECK(c1.their_shachain.id == 1);
|
|
|
|
|
|
|
|
|
|
/* Variant 5: update with remote_ann sigs */
|
|
|
|
|
/* set flag of CHANNEL_FLAGS_ANNOUNCE_CHANNEL */
|
|
|
|
|
c1.channel_flags |= 1;
|
|
|
|
|
wallet_channel_save(w, &c1);
|
|
|
|
|
CHECK_MSG(!wallet_err,
|
|
|
|
|
tal_fmt(w, "Insert into DB: %s", wallet_err));
|
|
|
|
|
wallet_announcement_save(w, c1.dbid, node_sig1, bitcoin_sig1);
|
|
|
|
|
CHECK_MSG(!wallet_err,
|
|
|
|
|
tal_fmt(w, "Insert ann sigs into DB: %s", wallet_err));
|
2024-01-31 13:46:17 +10:30
|
|
|
node_sig2 = tal(tmpctx, secp256k1_ecdsa_signature);
|
|
|
|
|
bitcoin_sig2 = tal(tmpctx, secp256k1_ecdsa_signature);
|
|
|
|
|
CHECK_MSG(load = wallet_remote_ann_sigs_load(w, &c1, node_sig2, bitcoin_sig2), tal_fmt(w, "Load ann sigs from DB"));
|
2019-05-02 02:17:31 +08:00
|
|
|
CHECK_MSG(!wallet_err,
|
|
|
|
|
tal_fmt(w, "Load ann sigs from DB: %s", wallet_err));
|
|
|
|
|
CHECK(load == true);
|
|
|
|
|
CHECK_MSG(!memcmp(node_sig1, node_sig2, sizeof(*node_sig1)), "Compare ann sigs loaded with saved (v5)");
|
|
|
|
|
CHECK_MSG(!memcmp(bitcoin_sig1, bitcoin_sig2, sizeof(*node_sig1)), "Compare ann sigs loaded with saved (v5)");
|
2024-01-31 13:46:17 +10:30
|
|
|
wallet_remote_ann_sigs_clear(w, &c1);
|
|
|
|
|
CHECK(!wallet_remote_ann_sigs_load(w, &c1, node_sig2, bitcoin_sig2));
|
2019-05-02 02:17:31 +08:00
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
db_commit_transaction(w->db);
|
|
|
|
|
CHECK(!wallet_err);
|
2019-05-02 02:17:31 +08:00
|
|
|
|
2018-02-14 12:23:04 +10:30
|
|
|
/* Normally freed by destroy_channel, but we don't call that */
|
|
|
|
|
tal_free(p);
|
2017-08-05 12:28:44 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
static int count_inflights(struct wallet *w, u64 channel_dbid)
|
|
|
|
|
{
|
|
|
|
|
struct db_stmt *stmt;
|
|
|
|
|
int count;
|
|
|
|
|
stmt = db_prepare_v2(w->db, SQL("SELECT COUNT(1)"
|
|
|
|
|
" FROM channel_funding_inflights"
|
|
|
|
|
" WHERE channel_id = ?;"));
|
2023-07-14 09:58:46 +09:30
|
|
|
db_bind_u64(stmt, channel_dbid);
|
2021-02-04 15:14:44 -06:00
|
|
|
db_query_prepared(stmt);
|
|
|
|
|
if (!db_step(stmt))
|
|
|
|
|
abort();
|
2021-11-15 04:26:46 +10:30
|
|
|
count = db_col_int(stmt, "COUNT(1)");
|
2021-02-04 15:14:44 -06:00
|
|
|
tal_free(stmt);
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
|
|
|
|
|
{
|
|
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
|
|
|
|
struct channel *chan, *c2;
|
|
|
|
|
struct channel_inflight *inflight;
|
2021-10-13 14:15:36 +10:30
|
|
|
struct bitcoin_outpoint outpoint;
|
2021-02-04 15:14:44 -06:00
|
|
|
struct bitcoin_signature sig;
|
|
|
|
|
struct amount_sat funding_sats, our_sats;
|
|
|
|
|
struct node_id id;
|
|
|
|
|
struct pubkey pk;
|
|
|
|
|
struct wireaddr_internal addr;
|
|
|
|
|
struct peer *p;
|
|
|
|
|
struct channel_config our_config;
|
|
|
|
|
struct channel_id cid;
|
|
|
|
|
struct bitcoin_tx *last_tx;
|
|
|
|
|
struct wally_psbt *funding_psbt;
|
|
|
|
|
struct channel_info *channel_info = tal(w, struct channel_info);
|
|
|
|
|
struct basepoints basepoints;
|
2025-08-14 12:40:11 +09:30
|
|
|
struct short_channel_id alias_local = random_scid();
|
2021-06-22 13:25:59 -05:00
|
|
|
secp256k1_ecdsa_signature *lease_commit_sig;
|
|
|
|
|
u32 feerate, lease_blockheight_start;
|
2021-02-04 15:14:44 -06:00
|
|
|
u64 dbid;
|
2024-09-19 16:30:37 +09:30
|
|
|
struct channel_stats *stats = talz(w, struct channel_stats);
|
2021-02-04 15:14:44 -06:00
|
|
|
|
|
|
|
|
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
|
|
|
|
|
node_id_from_pubkey(&id, &pk);
|
2023-05-30 13:58:18 +09:30
|
|
|
assert(parse_wireaddr_internal(tmpctx, "localhost:1234", 0, false, &addr) == NULL);
|
2021-02-04 15:14:44 -06:00
|
|
|
|
|
|
|
|
/* new channel! */
|
2024-11-24 12:09:16 +10:30
|
|
|
p = new_peer(ld, 0, &id, &addr, NULL, NULL, false);
|
2021-02-04 15:14:44 -06:00
|
|
|
|
|
|
|
|
funding_sats = AMOUNT_SAT(4444444);
|
|
|
|
|
our_sats = AMOUNT_SAT(3333333);
|
|
|
|
|
mempat(&sig.s, sizeof(sig.s));
|
|
|
|
|
mempat(&cid, sizeof(struct channel_id));
|
2021-06-22 13:25:59 -05:00
|
|
|
|
|
|
|
|
lease_commit_sig = tal(w, secp256k1_ecdsa_signature);
|
|
|
|
|
mempat(lease_commit_sig, sizeof(*lease_commit_sig));
|
|
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
sig.sighash_type = SIGHASH_ALL;
|
|
|
|
|
|
|
|
|
|
/* last_tx taken from BOLT #3 */
|
|
|
|
|
last_tx = bitcoin_tx_from_hex(w, "02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220", strlen("02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8003a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110ae8f6a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e040047304402206a2679efa3c7aaffd2a447fd0df7aba8792858b589750f6a1203f9259173198a022008d52a0e77a99ab533c36206cb15ad7aeb2aa72b93d4b571e728cb5ec2f6fe260147304402206d6cb93969d39177a09d5d45b583f34966195b77c7e585cf47ac5cce0c90cefb022031d71ae4e33a4e80df7f981d696fbdee517337806a3c7138b7491e2cbb077a0e01475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220"));
|
|
|
|
|
funding_psbt = psbt_from_b64(w, "cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA", strlen("cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA"));
|
|
|
|
|
feerate = 192838;
|
2021-06-22 13:25:59 -05:00
|
|
|
lease_blockheight_start = 101010;
|
2021-02-04 15:14:44 -06:00
|
|
|
memset(&our_config, 1, sizeof(struct channel_config));
|
|
|
|
|
our_config.id = 0;
|
2021-10-13 14:15:36 +10:30
|
|
|
memset(&outpoint, 1, sizeof(outpoint));
|
2021-02-04 15:14:44 -06:00
|
|
|
basepoints.revocation = pk;
|
|
|
|
|
basepoints.payment = pk;
|
|
|
|
|
basepoints.htlc = pk;
|
|
|
|
|
basepoints.delayed_payment = pk;
|
|
|
|
|
memset(channel_info, 3, sizeof(*channel_info));
|
|
|
|
|
channel_info->their_config.id = 0;
|
|
|
|
|
channel_info->remote_fundingkey = pk;
|
|
|
|
|
channel_info->theirbase = basepoints;
|
|
|
|
|
channel_info->remote_per_commit = pk;
|
|
|
|
|
channel_info->old_remote_per_commit = pk;
|
|
|
|
|
chan = new_channel(p, wallet_get_channel_dbid(w),
|
|
|
|
|
NULL,
|
|
|
|
|
DUALOPEND_AWAITING_LOCKIN,
|
|
|
|
|
LOCAL, NULL, "billboard",
|
2023-01-12 13:14:47 -06:00
|
|
|
8, false, false, &our_config,
|
2021-02-04 15:14:44 -06:00
|
|
|
101, 1, 1, 1,
|
2021-10-13 14:15:36 +10:30
|
|
|
&outpoint,
|
2021-02-04 15:14:44 -06:00
|
|
|
funding_sats, AMOUNT_MSAT(0),
|
|
|
|
|
our_sats,
|
2025-08-14 12:40:06 +09:30
|
|
|
0, NULL,
|
|
|
|
|
NULL, /* old scids */
|
2025-08-14 12:40:11 +09:30
|
|
|
alias_local,
|
2022-04-22 12:57:01 +02:00
|
|
|
NULL, /* alias[REMOTE] */
|
2021-02-04 15:14:44 -06:00
|
|
|
&cid,
|
|
|
|
|
AMOUNT_MSAT(3333333000),
|
|
|
|
|
AMOUNT_MSAT(33333),
|
|
|
|
|
AMOUNT_MSAT(3333333333),
|
|
|
|
|
last_tx, &sig,
|
|
|
|
|
NULL,
|
|
|
|
|
channel_info,
|
|
|
|
|
new_fee_states(w, LOCAL, &feerate),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
1, false,
|
|
|
|
|
NULL,
|
|
|
|
|
100, /* first_blocknum */
|
|
|
|
|
100, /* min_possible_feerate */
|
|
|
|
|
10000, /* max_possible_feerate */
|
|
|
|
|
&basepoints,
|
|
|
|
|
&pk, NULL,
|
|
|
|
|
1000, 100,
|
2021-09-09 14:59:35 +09:30
|
|
|
NULL, 0, 0, channel_type_static_remotekey(NULL),
|
2024-11-26 01:12:43 +10:30
|
|
|
LOCAL, 0, REASON_UNKNOWN,
|
2021-06-22 13:25:59 -05:00
|
|
|
NULL,
|
|
|
|
|
new_height_states(w, LOCAL,
|
|
|
|
|
&lease_blockheight_start),
|
|
|
|
|
100,
|
|
|
|
|
lease_commit_sig,
|
2022-03-21 11:28:23 +10:30
|
|
|
7777, 22,
|
2022-03-21 11:28:54 +10:30
|
|
|
AMOUNT_MSAT(0),
|
2023-07-21 16:45:22 +09:30
|
|
|
AMOUNT_MSAT(-1ULL),
|
2023-12-07 06:44:05 +10:30
|
|
|
false,
|
2024-01-31 13:46:19 +10:30
|
|
|
NULL,
|
2024-09-19 16:30:37 +09:30
|
|
|
0,
|
2024-09-19 16:34:20 +09:30
|
|
|
stats,
|
2025-11-18 14:36:04 +10:30
|
|
|
tal_arr(NULL, struct channel_state_change *, 0),
|
2025-11-18 14:42:04 +10:30
|
|
|
NULL,
|
|
|
|
|
false);
|
2021-02-04 15:14:44 -06:00
|
|
|
db_begin_transaction(w->db);
|
|
|
|
|
CHECK(!wallet_err);
|
|
|
|
|
wallet_channel_insert(w, chan);
|
|
|
|
|
|
|
|
|
|
/* info for the inflight */
|
|
|
|
|
funding_sats = AMOUNT_SAT(222222);
|
|
|
|
|
our_sats = AMOUNT_SAT(111111);
|
2021-10-13 14:15:36 +10:30
|
|
|
memset(&outpoint, 1, sizeof(outpoint));
|
2021-02-04 15:14:44 -06:00
|
|
|
mempat(&sig.s, sizeof(sig.s));
|
|
|
|
|
|
2024-10-04 14:44:50 -04:00
|
|
|
inflight = new_inflight(chan, NULL, &outpoint, 253,
|
2021-02-04 15:14:44 -06:00
|
|
|
funding_sats,
|
|
|
|
|
our_sats,
|
|
|
|
|
funding_psbt,
|
2021-12-08 11:42:07 -06:00
|
|
|
1, lease_commit_sig, 2, 4, 22,
|
2022-10-24 13:12:36 -05:00
|
|
|
AMOUNT_MSAT(10),
|
2023-07-27 14:37:52 -07:00
|
|
|
AMOUNT_SAT(1111),
|
|
|
|
|
0,
|
2023-11-02 20:08:33 -04:00
|
|
|
false,
|
2025-06-18 18:50:20 -04:00
|
|
|
false,
|
2023-07-27 14:37:52 -07:00
|
|
|
false);
|
2025-02-01 10:41:33 -05:00
|
|
|
inflight->splice_locked_memonly = true;
|
|
|
|
|
inflight->locked_scid = tal(inflight, struct short_channel_id);
|
|
|
|
|
memset(inflight->locked_scid, 7, sizeof(struct short_channel_id));
|
2021-02-04 15:14:44 -06:00
|
|
|
|
2023-10-26 11:41:34 -05:00
|
|
|
inflight_set_last_tx(inflight, last_tx, sig);
|
|
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
/* do inflights get correctly added to the channel? */
|
|
|
|
|
wallet_inflight_add(w, inflight);
|
|
|
|
|
|
2025-08-19 10:30:45 +09:30
|
|
|
/* Hack to remove scid & dbid from htables so we don't clash! */
|
2025-08-14 12:40:11 +09:30
|
|
|
chanmap_remove(ld, chan, *chan->alias[LOCAL]);
|
2025-08-19 10:30:45 +09:30
|
|
|
remove_from_dbid_map(chan);
|
|
|
|
|
tal_del_destructor(chan, remove_from_dbid_map);
|
2025-08-14 12:40:11 +09:30
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
/* do inflights get correctly loaded from the database? */
|
|
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, chan->dbid),
|
|
|
|
|
tal_fmt(w, "Load from DB"));
|
|
|
|
|
CHECK_MSG(channelseq(chan, c2), "Compare loaded with saved (v2)");
|
|
|
|
|
tal_free(c2);
|
|
|
|
|
|
|
|
|
|
/* add another inflight, confirm existence */
|
|
|
|
|
funding_sats = AMOUNT_SAT(666666);
|
|
|
|
|
our_sats = AMOUNT_SAT(555555);
|
2021-10-13 14:15:36 +10:30
|
|
|
memset(&outpoint, 2, sizeof(outpoint));
|
2021-02-04 15:14:44 -06:00
|
|
|
mempat(&sig.s, sizeof(sig.s));
|
2024-10-04 14:44:50 -04:00
|
|
|
inflight = new_inflight(chan, NULL, &outpoint, 300,
|
2021-02-04 15:14:44 -06:00
|
|
|
funding_sats,
|
|
|
|
|
our_sats,
|
|
|
|
|
funding_psbt,
|
2021-12-08 11:42:07 -06:00
|
|
|
0, NULL, 0, 0, 0,
|
2022-10-24 13:12:36 -05:00
|
|
|
AMOUNT_MSAT(0),
|
2023-07-27 14:37:52 -07:00
|
|
|
AMOUNT_SAT(0),
|
|
|
|
|
0,
|
2023-11-02 20:08:33 -04:00
|
|
|
false,
|
2025-06-18 18:50:20 -04:00
|
|
|
false,
|
2023-07-27 14:37:52 -07:00
|
|
|
false);
|
2025-02-01 10:41:33 -05:00
|
|
|
inflight->splice_locked_memonly = false;
|
|
|
|
|
inflight->locked_scid = NULL;
|
2023-10-26 11:41:34 -05:00
|
|
|
inflight_set_last_tx(inflight, last_tx, sig);
|
2021-02-04 15:14:44 -06:00
|
|
|
wallet_inflight_add(w, inflight);
|
|
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, chan->dbid),
|
|
|
|
|
tal_fmt(w, "Load from DB"));
|
|
|
|
|
CHECK_MSG(channelseq(chan, c2), "Compare loaded with saved (v2)");
|
|
|
|
|
CHECK_MSG(count_inflights(w, chan->dbid) == 2, "inflights exist");
|
2021-06-22 13:25:59 -05:00
|
|
|
|
2021-02-04 15:14:44 -06:00
|
|
|
tal_free(c2);
|
|
|
|
|
|
|
|
|
|
/* Update the PSBT for both inflights, check that are updated
|
|
|
|
|
* correctly on save */
|
2023-01-31 09:46:49 -05:00
|
|
|
funding_psbt = psbt_from_b64(w, "cHNidP8BAD8CAAAAAf//////////////////////////////////////////AAAAAAD/////AQAAAAAAAAAAA2oBAAAAAAAADfwB7g8BAgMEBQYHCAkPAQIDBAUGBwgJCgsMDQ4PAAA=", strlen("cHNidP8BAD8CAAAAAf//////////////////////////////////////////AAAAAAD/////AQAAAAAAAAAAA2oBAAAAAAAADfwB7g8BAgMEBQYHCAkPAQIDBAUGBwgJCgsMDQ4PAAA="));
|
2021-02-04 15:14:44 -06:00
|
|
|
list_for_each(&chan->inflights, inflight, list)
|
|
|
|
|
inflight->funding_psbt = funding_psbt;
|
|
|
|
|
wallet_channel_save(w, chan);
|
|
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, chan->dbid),
|
|
|
|
|
tal_fmt(w, "Load from DB"));
|
|
|
|
|
CHECK_MSG(channelseq(chan, c2), "Compare loaded with saved (v2)");
|
|
|
|
|
tal_free(c2);
|
|
|
|
|
|
|
|
|
|
/* do inflights get cleared when the channel is closed?*/
|
|
|
|
|
dbid = chan->dbid;
|
2025-04-29 09:55:08 +09:30
|
|
|
delete_channel(chan, true); /* Also clears up peer! */
|
2021-02-04 15:14:44 -06:00
|
|
|
CHECK_MSG(count_inflights(w, dbid) == 0, "inflights cleaned up");
|
|
|
|
|
db_commit_transaction(w->db);
|
|
|
|
|
CHECK_MSG(!wallet_err, wallet_err);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static bool test_channel_config_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-08-05 14:52:39 +02:00
|
|
|
{
|
|
|
|
|
struct channel_config *cc1 = talz(ctx, struct channel_config),
|
|
|
|
|
*cc2 = talz(ctx, struct channel_config);
|
2018-02-12 20:42:55 +10:30
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2017-08-05 14:52:39 +02:00
|
|
|
CHECK(w);
|
|
|
|
|
|
2019-02-21 14:15:54 +10:30
|
|
|
cc1->dust_limit.satoshis = 1;
|
|
|
|
|
cc1->max_htlc_value_in_flight.millisatoshis = 2;
|
|
|
|
|
cc1->channel_reserve.satoshis = 3;
|
|
|
|
|
cc1->htlc_minimum.millisatoshis = 4;
|
2017-08-05 14:52:39 +02:00
|
|
|
cc1->to_self_delay = 5;
|
|
|
|
|
cc1->max_accepted_htlcs = 6;
|
|
|
|
|
|
2018-02-18 23:24:46 +10:30
|
|
|
CHECK(transaction_wrap(w->db, wallet_channel_config_insert(w, cc1)));
|
2017-08-05 14:52:39 +02:00
|
|
|
CHECK_MSG(
|
|
|
|
|
cc1->id == 1,
|
|
|
|
|
tal_fmt(ctx, "channel_config->id != 1; got %" PRIu64, cc1->id));
|
2018-02-18 23:24:46 +10:30
|
|
|
CHECK(transaction_wrap(w->db, wallet_channel_config_save(w, cc1)));
|
2017-08-05 14:52:39 +02:00
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK(transaction_wrap(w->db, wallet_channel_config_load(w, cc1->id, cc2)));
|
2017-08-05 14:52:39 +02:00
|
|
|
CHECK(memeq(cc1, sizeof(*cc1), cc2, sizeof(*cc2)));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static bool test_htlc_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-09-14 21:27:41 +02:00
|
|
|
{
|
2019-08-13 16:00:46 +02:00
|
|
|
struct db_stmt *stmt;
|
2025-04-28 14:16:28 +09:30
|
|
|
struct htlc_in in, in2, *hin;
|
|
|
|
|
struct htlc_out out, out2, *hout;
|
2017-09-14 21:27:41 +02:00
|
|
|
struct preimage payment_key;
|
2018-02-12 20:42:55 +10:30
|
|
|
struct channel *chan = tal(ctx, struct channel);
|
2017-09-26 16:15:43 +02:00
|
|
|
struct peer *peer = talz(ctx, struct peer);
|
2018-02-12 20:42:55 +10:30
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2019-12-12 10:09:10 +10:30
|
|
|
struct htlc_in_map *htlcs_in = tal(ctx, struct htlc_in_map), *rem;
|
2017-09-26 16:15:43 +02:00
|
|
|
struct htlc_out_map *htlcs_out = tal(ctx, struct htlc_out_map);
|
2020-01-23 10:08:04 +10:30
|
|
|
struct onionreply *onionreply;
|
2025-04-28 14:13:56 +09:30
|
|
|
bool we_filled = false;
|
2017-09-14 21:27:41 +02:00
|
|
|
|
|
|
|
|
/* Make sure we have our references correct */
|
2019-08-08 21:21:12 +02:00
|
|
|
db_begin_transaction(w->db);
|
2019-08-13 16:00:46 +02:00
|
|
|
char *query = SQL("INSERT INTO channels (id) VALUES (1);");
|
|
|
|
|
stmt = db_prepare_v2(w->db, query);
|
|
|
|
|
db_exec_prepared_v2(stmt);
|
|
|
|
|
tal_free(stmt);
|
2019-08-08 21:21:12 +02:00
|
|
|
db_commit_transaction(w->db);
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
chan->dbid = 1;
|
2024-05-29 11:10:03 +02:00
|
|
|
chan->state = CHANNELD_NORMAL;
|
2017-09-26 16:15:43 +02:00
|
|
|
chan->peer = peer;
|
2021-10-13 14:15:30 +10:30
|
|
|
chan->next_index[LOCAL] = chan->next_index[REMOTE] = 1;
|
2025-04-28 14:16:28 +09:30
|
|
|
chan->scid = tal(chan, struct short_channel_id);
|
2017-09-14 21:27:41 +02:00
|
|
|
|
|
|
|
|
memset(&in, 0, sizeof(in));
|
|
|
|
|
memset(&out, 0, sizeof(out));
|
|
|
|
|
memset(&in.payment_hash, 'A', sizeof(struct sha256));
|
|
|
|
|
memset(&out.payment_hash, 'A', sizeof(struct sha256));
|
|
|
|
|
memset(&payment_key, 'B', sizeof(payment_key));
|
2025-04-28 14:16:28 +09:30
|
|
|
assert(mk_short_channel_id(chan->scid, 1, 2, 3));
|
2017-09-26 16:15:43 +02:00
|
|
|
in.key.id = 42;
|
2018-02-12 20:43:04 +10:30
|
|
|
in.key.channel = chan;
|
2025-04-28 14:16:28 +09:30
|
|
|
in.cltv_expiry = 42;
|
2019-02-21 14:15:55 +10:30
|
|
|
in.msat = AMOUNT_MSAT(42);
|
2017-09-26 16:15:43 +02:00
|
|
|
|
2017-09-14 21:27:41 +02:00
|
|
|
out.in = ∈
|
|
|
|
|
out.key.id = 1337;
|
2018-02-12 20:43:04 +10:30
|
|
|
out.key.channel = chan;
|
2025-04-28 14:16:28 +09:30
|
|
|
out.cltv_expiry = 41;
|
2019-02-21 14:15:55 +10:30
|
|
|
out.msat = AMOUNT_MSAT(41);
|
2017-09-14 21:27:41 +02:00
|
|
|
|
|
|
|
|
/* Store the htlc_in */
|
2017-11-01 11:40:48 +10:30
|
|
|
CHECK_MSG(transaction_wrap(w->db, wallet_htlc_save_in(w, chan, &in)),
|
2017-11-01 11:51:56 +10:30
|
|
|
tal_fmt(ctx, "Save htlc_in failed: %s", wallet_err));
|
2017-09-14 21:27:41 +02:00
|
|
|
CHECK_MSG(in.dbid != 0, "HTLC DB ID was not set.");
|
2025-04-28 14:16:28 +09:30
|
|
|
in2 = in;
|
|
|
|
|
/* Saving again should get us a collision (but overwrites dbid!) */
|
|
|
|
|
CHECK_MSG(!transaction_wrap(w->db, wallet_htlc_save_in(w, chan, &in2)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Saving two HTLCs with the same data must not succeed.");
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK(wallet_err);
|
|
|
|
|
wallet_err = tal_free(wallet_err);
|
2017-11-01 11:40:48 +10:30
|
|
|
|
2017-09-14 21:27:41 +02:00
|
|
|
/* Update */
|
2025-04-28 14:16:28 +09:30
|
|
|
CHECK_MSG(transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, RCVD_ADD_HTLC, NULL, 0, 0, NULL, NULL, &we_filled, in.key.id, in.key.channel, REMOTE, &in.payment_hash, in.cltv_expiry, in.msat)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Update HTLC with null payment_key failed");
|
|
|
|
|
CHECK_MSG(
|
2025-04-28 14:16:28 +09:30
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, SENT_REMOVE_HTLC, &payment_key, 0, 0, NULL, NULL, &we_filled, in.key.id, in.key.channel, REMOTE, &in.payment_hash, in.cltv_expiry, in.msat)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Update HTLC with payment_key failed");
|
2020-01-23 10:08:04 +10:30
|
|
|
onionreply = new_onionreply(tmpctx, tal_arrz(tmpctx, u8, 100));
|
2018-10-09 19:26:52 +10:30
|
|
|
CHECK_MSG(
|
2025-04-28 14:16:28 +09:30
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, SENT_REMOVE_HTLC, NULL, 0, 0, onionreply, NULL, &we_filled, in.key.id, in.key.channel, REMOTE, &in.payment_hash, in.cltv_expiry, in.msat)),
|
2020-02-18 10:30:58 +10:30
|
|
|
"Update HTLC with failonion failed");
|
|
|
|
|
CHECK_MSG(
|
2025-04-28 14:16:28 +09:30
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, SENT_REMOVE_HTLC, NULL, 0, WIRE_INVALID_ONION_VERSION, NULL, NULL, &we_filled, in.key.id, in.key.channel, REMOTE, &in.payment_hash, in.cltv_expiry, in.msat)),
|
2020-02-18 10:30:58 +10:30
|
|
|
"Update HTLC with failcode failed");
|
2017-09-14 21:27:41 +02:00
|
|
|
|
2017-11-01 11:40:48 +10:30
|
|
|
CHECK_MSG(transaction_wrap(w->db, wallet_htlc_save_out(w, chan, &out)),
|
2017-11-01 11:51:56 +10:30
|
|
|
tal_fmt(ctx, "Save htlc_out failed: %s", wallet_err));
|
2017-09-14 21:27:41 +02:00
|
|
|
CHECK_MSG(out.dbid != 0, "HTLC DB ID was not set.");
|
2017-11-01 11:40:48 +10:30
|
|
|
|
2025-04-28 14:16:28 +09:30
|
|
|
out2 = out;
|
|
|
|
|
CHECK_MSG(!transaction_wrap(w->db, wallet_htlc_save_out(w, chan, &out2)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Saving two HTLCs with the same data must not succeed.");
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK(wallet_err);
|
|
|
|
|
wallet_err = tal_free(wallet_err);
|
2020-02-18 10:30:58 +10:30
|
|
|
CHECK_MSG(
|
2025-04-28 14:16:28 +09:30
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, out.dbid, SENT_ADD_ACK_REVOCATION, NULL, 0, 0, NULL, tal_arrz(tmpctx, u8, 100), &we_filled, out.key.id, out.key.channel, REMOTE, &out.payment_hash, out.cltv_expiry, out.msat)),
|
2020-02-18 10:30:58 +10:30
|
|
|
"Update outgoing HTLC with failmsg failed");
|
2017-09-25 20:44:23 +02:00
|
|
|
|
|
|
|
|
/* Attempt to load them from the DB again */
|
2017-09-26 16:15:43 +02:00
|
|
|
htlc_in_map_init(htlcs_in);
|
|
|
|
|
htlc_out_map_init(htlcs_out);
|
2017-09-25 20:44:23 +02:00
|
|
|
|
2017-11-01 11:51:56 +10:30
|
|
|
db_begin_transaction(w->db);
|
|
|
|
|
CHECK(!wallet_err);
|
|
|
|
|
|
2019-12-12 10:09:10 +10:30
|
|
|
CHECK_MSG(wallet_htlcs_load_in_for_channel(w, chan, htlcs_in),
|
|
|
|
|
"Failed loading in HTLCs");
|
|
|
|
|
/* Freed by htlcs_resubmit */
|
|
|
|
|
rem = tal(NULL, struct htlc_in_map);
|
|
|
|
|
htlc_in_map_copy(rem, htlcs_in);
|
|
|
|
|
CHECK_MSG(wallet_htlcs_load_out_for_channel(w, chan, htlcs_out, rem),
|
|
|
|
|
"Failed loading out HTLCs");
|
2017-11-01 11:51:56 +10:30
|
|
|
db_commit_transaction(w->db);
|
2018-09-03 10:38:53 +09:30
|
|
|
|
2019-12-12 10:09:10 +10:30
|
|
|
htlcs_resubmit(w->ld, rem);
|
2017-11-01 11:51:56 +10:30
|
|
|
CHECK(!wallet_err);
|
2017-09-26 16:15:43 +02:00
|
|
|
|
|
|
|
|
hin = htlc_in_map_get(htlcs_in, &in.key);
|
|
|
|
|
hout = htlc_out_map_get(htlcs_out, &out.key);
|
|
|
|
|
|
|
|
|
|
CHECK(hin != NULL);
|
|
|
|
|
CHECK(hout != NULL);
|
|
|
|
|
|
|
|
|
|
/* Have to free manually, otherwise we get our dependencies
|
|
|
|
|
* twisted */
|
|
|
|
|
tal_free(hin);
|
|
|
|
|
tal_free(hout);
|
|
|
|
|
|
2017-09-14 21:27:41 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-12 20:42:55 +10:30
|
|
|
static bool test_payment_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-11-10 15:54:56 +01:00
|
|
|
{
|
2023-10-28 13:38:17 +10:30
|
|
|
struct wallet_payment *t, *t2;
|
2018-02-12 20:42:55 +10:30
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2023-10-28 13:38:17 +10:30
|
|
|
struct sha256 payment_hash;
|
|
|
|
|
struct node_id destination;
|
2017-11-10 15:54:56 +01:00
|
|
|
|
2023-10-28 13:38:17 +10:30
|
|
|
memset(&payment_hash, 1, sizeof(payment_hash));
|
|
|
|
|
memset(&destination, 2, sizeof(struct node_id));
|
2017-11-10 15:54:56 +01:00
|
|
|
|
|
|
|
|
db_begin_transaction(w->db);
|
2023-10-28 11:08:09 +10:30
|
|
|
load_indexes(w->db, ld->indexes);
|
2023-10-28 13:38:17 +10:30
|
|
|
t = wallet_add_payment(ctx,
|
|
|
|
|
w,
|
|
|
|
|
1,
|
|
|
|
|
NULL,
|
|
|
|
|
&payment_hash,
|
|
|
|
|
0, 12345,
|
|
|
|
|
PAYMENT_PENDING,
|
|
|
|
|
&destination,
|
|
|
|
|
AMOUNT_MSAT(100),
|
|
|
|
|
AMOUNT_MSAT(101),
|
|
|
|
|
AMOUNT_MSAT(100),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2021-09-29 19:10:12 +02:00
|
|
|
t2 = wallet_payment_by_hash(ctx, w, &t->payment_hash, 0, t->groupid);
|
2017-11-10 15:54:56 +01:00
|
|
|
CHECK(t2 != NULL);
|
2018-01-18 06:59:49 +10:30
|
|
|
CHECK(t2->status == t->status);
|
2019-12-12 09:46:23 +10:30
|
|
|
CHECK(sha256_eq(&t2->payment_hash, &t->payment_hash));
|
|
|
|
|
CHECK(t2->partid == t->partid);
|
2019-11-07 23:13:29 +01:00
|
|
|
CHECK(node_id_cmp(t2->destination, t->destination) == 0);
|
2019-02-21 14:15:55 +10:30
|
|
|
CHECK(amount_msat_eq(t2->msatoshi, t->msatoshi));
|
|
|
|
|
CHECK(amount_msat_eq(t2->msatoshi_sent, t->msatoshi_sent));
|
2019-12-12 09:46:23 +10:30
|
|
|
CHECK(amount_msat_eq(t2->total_msat, t->total_msat));
|
2018-01-18 06:59:49 +10:30
|
|
|
CHECK(!t2->payment_preimage);
|
2017-11-10 15:54:56 +01:00
|
|
|
|
2018-01-18 06:59:49 +10:30
|
|
|
t->status = PAYMENT_COMPLETE;
|
|
|
|
|
t->payment_preimage = tal(w, struct preimage);
|
|
|
|
|
memset(t->payment_preimage, 2, sizeof(*t->payment_preimage));
|
2021-09-29 12:33:57 +02:00
|
|
|
wallet_payment_set_status(w, &t->payment_hash, t->partid, t->groupid,
|
|
|
|
|
t->status, t->payment_preimage);
|
2021-09-29 19:10:12 +02:00
|
|
|
t2 = wallet_payment_by_hash(ctx, w, &t->payment_hash, t->partid, t->groupid);
|
2018-01-18 06:52:22 +10:30
|
|
|
CHECK(t2 != NULL);
|
2018-01-18 06:59:49 +10:30
|
|
|
CHECK(t2->status == t->status);
|
2019-12-12 09:46:23 +10:30
|
|
|
CHECK(sha256_eq(&t2->payment_hash, &t->payment_hash));
|
|
|
|
|
CHECK(t2->partid == t->partid);
|
2019-11-07 23:13:29 +01:00
|
|
|
CHECK(node_id_eq(t2->destination, t->destination));
|
2019-02-21 14:15:55 +10:30
|
|
|
CHECK(amount_msat_eq(t2->msatoshi, t->msatoshi));
|
|
|
|
|
CHECK(amount_msat_eq(t2->msatoshi_sent, t->msatoshi_sent));
|
2018-07-04 15:00:02 +09:30
|
|
|
CHECK(preimage_eq(t->payment_preimage, t2->payment_preimage));
|
2017-11-10 15:54:56 +01:00
|
|
|
|
|
|
|
|
db_commit_transaction(w->db);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-27 12:55:37 +02:00
|
|
|
static bool test_wallet_payment_status_enum(void)
|
|
|
|
|
{
|
|
|
|
|
CHECK(PAYMENT_PENDING == 0);
|
|
|
|
|
CHECK(PAYMENT_COMPLETE == 1);
|
|
|
|
|
CHECK(PAYMENT_FAILED == 2);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 17:13:22 -05:00
|
|
|
int main(int argc, const char *argv[])
|
2017-05-31 15:26:30 +02:00
|
|
|
{
|
2020-05-15 17:13:22 -05:00
|
|
|
common_setup(argv[0]);
|
2019-09-26 00:42:26 +02:00
|
|
|
chainparams = chainparams_for_network("bitcoin");
|
2018-04-25 12:55:34 +02:00
|
|
|
|
2017-05-31 15:26:30 +02:00
|
|
|
bool ok = true;
|
2018-03-15 16:40:20 +10:30
|
|
|
struct lightningd *ld;
|
|
|
|
|
|
|
|
|
|
ld = tal(tmpctx, struct lightningd);
|
2019-03-13 17:20:54 +01:00
|
|
|
ld->config = test_config;
|
2023-03-21 14:28:09 +10:30
|
|
|
ld->hsm_capabilities = NULL;
|
2025-11-13 16:02:39 +10:30
|
|
|
ld->developer = true;
|
2025-04-28 14:16:28 +09:30
|
|
|
memset(&ld->indexes[WAIT_SUBSYSTEM_HTLCS], 0,
|
|
|
|
|
sizeof(ld->indexes[WAIT_SUBSYSTEM_HTLCS]));
|
2018-02-12 20:42:55 +10:30
|
|
|
|
|
|
|
|
/* Only elements in ld we should access */
|
2023-01-18 15:34:32 +10:30
|
|
|
ld->peers = tal(ld, struct peer_node_id_map);
|
|
|
|
|
peer_node_id_map_init(ld->peers);
|
2023-01-18 15:34:32 +10:30
|
|
|
ld->peers_by_dbid = tal(ld, struct peer_dbid_map);
|
|
|
|
|
peer_dbid_map_init(ld->peers_by_dbid);
|
2020-09-08 14:27:53 +09:30
|
|
|
ld->rr_counter = 0;
|
2024-07-18 10:55:55 +09:30
|
|
|
node_id_from_hexstr("02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66, &ld->our_nodeid);
|
2018-02-12 20:42:55 +10:30
|
|
|
/* Accessed in peer destructor sanity check */
|
2023-01-03 15:16:52 +10:30
|
|
|
ld->htlcs_in = tal(ld, struct htlc_in_map);
|
|
|
|
|
htlc_in_map_init(ld->htlcs_in);
|
|
|
|
|
ld->htlcs_out = tal(ld, struct htlc_out_map);
|
|
|
|
|
htlc_out_map_init(ld->htlcs_out);
|
2023-10-28 11:08:09 +10:30
|
|
|
list_head_init(&ld->wait_commands);
|
2025-04-29 09:55:08 +09:30
|
|
|
ld->closed_channels = tal(ld, struct closed_channel_map);
|
|
|
|
|
closed_channel_map_init(ld->closed_channels);
|
2025-08-19 10:30:45 +09:30
|
|
|
ld->channels_by_dbid = tal(ld, struct channel_dbid_map);
|
|
|
|
|
channel_dbid_map_init(ld->channels_by_dbid);
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2022-03-28 10:58:12 +10:30
|
|
|
/* We do a runtime test here, so we still check compile! */
|
|
|
|
|
if (HAVE_SQLITE3) {
|
|
|
|
|
ok &= test_shachain_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_channel_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_channel_inflight_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_channel_config_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_channel_inflight_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_wallet_outputs(ld, tmpctx);
|
|
|
|
|
ok &= test_htlc_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_payment_crud(ld, tmpctx);
|
|
|
|
|
ok &= test_wallet_payment_status_enum();
|
|
|
|
|
}
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2018-06-04 16:19:14 +02:00
|
|
|
/* Do not clean up in the case of an error, we might want to debug the
|
|
|
|
|
* database. */
|
|
|
|
|
if (ok) {
|
2020-05-15 17:13:22 -05:00
|
|
|
common_shutdown();
|
2025-02-11 15:31:50 -06:00
|
|
|
trace_cleanup();
|
2018-06-04 16:19:14 +02:00
|
|
|
}
|
2017-05-31 15:26:30 +02:00
|
|
|
return !ok;
|
|
|
|
|
}
|