2017-11-01 02:10:48 +01:00
|
|
|
#include <lightningd/log.h>
|
|
|
|
|
2018-08-09 04:27:20 +02:00
|
|
|
static void wallet_test_fatal(const char *fmt, ...);
|
|
|
|
#define db_fatal wallet_test_fatal
|
2017-12-12 04:42:37 +01:00
|
|
|
#include "test_utils.h"
|
2017-11-01 02:10:48 +01:00
|
|
|
|
2019-11-17 12:41:33 +01:00
|
|
|
static void db_log_(struct log *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 05:03:42 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#define log_ db_log_
|
|
|
|
|
2017-12-12 04:42:37 +01:00
|
|
|
#include "wallet/wallet.c"
|
2018-02-05 05:09:27 +01:00
|
|
|
#include "lightningd/htlc_end.c"
|
2018-02-12 11:12:55 +01:00
|
|
|
#include "lightningd/peer_control.c"
|
2018-09-03 03:08:53 +02:00
|
|
|
#include "lightningd/peer_htlcs.c"
|
2018-02-12 11:12:55 +01:00
|
|
|
#include "lightningd/channel.c"
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2017-12-12 04:42:37 +01:00
|
|
|
#include "wallet/db.c"
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2017-09-26 14:43:09 +02:00
|
|
|
#include <ccan/mem/mem.h>
|
2017-11-01 02:10:48 +01:00
|
|
|
#include <ccan/tal/str/str.h>
|
2019-02-20 12:31:48 +01:00
|
|
|
#include <common/amount.h>
|
2020-01-26 13:52:29 +01:00
|
|
|
#include <common/errcode.h>
|
2017-12-15 11:17:54 +01:00
|
|
|
#include <common/memleak.h>
|
2020-05-16 00:13:22 +02:00
|
|
|
#include <common/setup.h>
|
2017-11-01 02:10:48 +01:00
|
|
|
#include <stdarg.h>
|
2017-12-20 12:44:00 +01:00
|
|
|
#include <stddef.h>
|
2017-05-31 15:26:30 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2018-03-28 04:32:39 +02:00
|
|
|
#include <wally_core.h>
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
bool deprecated_apis = true;
|
|
|
|
|
2017-12-12 04:42:38 +01:00
|
|
|
/* AUTOGENERATED MOCKS START */
|
2019-07-30 07:25:12 +02:00
|
|
|
/* Generated stub for bigsize_put */
|
|
|
|
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
|
|
|
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
2020-01-09 16:38:12 +01:00
|
|
|
/* Generated stub for bitcoind_getutxout_ */
|
|
|
|
void bitcoind_getutxout_(struct bitcoind *bitcoind UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED,
|
|
|
|
void (*cb)(struct bitcoind *bitcoind UNNEEDED,
|
|
|
|
const struct bitcoin_tx_output *txout UNNEEDED,
|
|
|
|
void *arg) UNNEEDED,
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "bitcoind_getutxout_ called!\n"); abort(); }
|
2020-04-11 05:22:40 +02:00
|
|
|
/* Generated stub for blinding_hash_e_and_ss */
|
|
|
|
void blinding_hash_e_and_ss(const struct pubkey *e UNNEEDED,
|
|
|
|
const struct secret *ss UNNEEDED,
|
|
|
|
struct sha256 *sha UNNEEDED)
|
|
|
|
{ fprintf(stderr, "blinding_hash_e_and_ss called!\n"); abort(); }
|
|
|
|
/* Generated stub for blinding_next_pubkey */
|
|
|
|
bool blinding_next_pubkey(const struct pubkey *pk UNNEEDED,
|
|
|
|
const struct sha256 *h UNNEEDED,
|
|
|
|
struct pubkey *next UNNEEDED)
|
|
|
|
{ fprintf(stderr, "blinding_next_pubkey called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for broadcast_tx */
|
|
|
|
void broadcast_tx(struct chain_topology *topo UNNEEDED,
|
2018-02-12 11:13:04 +01:00
|
|
|
struct channel *channel UNNEEDED, const struct bitcoin_tx *tx UNNEEDED,
|
|
|
|
void (*failed)(struct channel *channel UNNEEDED,
|
2020-01-09 12:25:45 +01:00
|
|
|
bool success UNNEEDED,
|
2018-02-12 11:12:55 +01:00
|
|
|
const char *err))
|
|
|
|
{ fprintf(stderr, "broadcast_tx called!\n"); abort(); }
|
2019-02-26 17:57:19 +01:00
|
|
|
/* Generated stub for channel_tell_depth */
|
|
|
|
bool channel_tell_depth(struct lightningd *ld UNNEEDED,
|
2018-04-23 12:08:01 +02:00
|
|
|
struct channel *channel UNNEEDED,
|
2018-05-17 07:08:11 +02:00
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
u32 depth UNNEEDED)
|
2019-02-26 17:57:19 +01:00
|
|
|
{ fprintf(stderr, "channel_tell_depth called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for command_fail */
|
2020-01-26 13:52:29 +01:00
|
|
|
struct command_result *command_fail(struct command *cmd UNNEEDED, errcode_t code UNNEEDED,
|
2018-12-16 05:49:06 +01:00
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "command_fail called!\n"); abort(); }
|
2018-12-16 05:52:06 +01:00
|
|
|
/* Generated stub for command_param_failed */
|
|
|
|
struct command_result *command_param_failed(void)
|
2018-12-17 04:52:08 +01:00
|
|
|
|
2018-12-16 05:52:06 +01:00
|
|
|
{ fprintf(stderr, "command_param_failed called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for command_still_pending */
|
2018-12-17 04:52:08 +01:00
|
|
|
struct command_result *command_still_pending(struct command *cmd)
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "command_still_pending called!\n"); abort(); }
|
|
|
|
/* Generated stub for command_success */
|
2018-12-16 05:49:06 +01:00
|
|
|
struct command_result *command_success(struct command *cmd UNNEEDED,
|
2018-12-17 04:52:08 +01:00
|
|
|
struct json_stream *response)
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "command_success called!\n"); abort(); }
|
2018-08-09 02:25:29 +02:00
|
|
|
/* Generated stub for connect_succeeded */
|
2020-04-02 06:07:47 +02:00
|
|
|
void connect_succeeded(struct lightningd *ld UNNEEDED, const struct peer *peer UNNEEDED)
|
2018-08-09 02:25:29 +02:00
|
|
|
{ fprintf(stderr, "connect_succeeded called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for create_onionreply */
|
|
|
|
struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED,
|
|
|
|
const struct secret *shared_secret UNNEEDED,
|
|
|
|
const u8 *failure_msg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "create_onionreply called!\n"); abort(); }
|
2018-08-09 02:25:29 +02:00
|
|
|
/* Generated stub for delay_then_reconnect */
|
2018-08-09 02:25:29 +02:00
|
|
|
void delay_then_reconnect(struct channel *channel UNNEEDED, u32 seconds_delay UNNEEDED,
|
|
|
|
const struct wireaddr_internal *addrhint TAKES UNNEEDED)
|
2018-08-09 02:25:29 +02:00
|
|
|
{ fprintf(stderr, "delay_then_reconnect called!\n"); abort(); }
|
2020-05-15 12:29:53 +02:00
|
|
|
/* Generated stub for derive_channel_id */
|
|
|
|
void derive_channel_id(struct channel_id *channel_id UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED, u16 txout UNNEEDED)
|
|
|
|
{ fprintf(stderr, "derive_channel_id called!\n"); abort(); }
|
2020-04-11 05:22:40 +02:00
|
|
|
/* Generated stub for ecdh */
|
|
|
|
void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED)
|
|
|
|
{ fprintf(stderr, "ecdh called!\n"); abort(); }
|
2019-10-29 18:00:18 +01:00
|
|
|
/* Generated stub for encode_scriptpubkey_to_addr */
|
|
|
|
char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED,
|
|
|
|
const struct chainparams *chainparams UNNEEDED,
|
2020-01-09 16:38:12 +01:00
|
|
|
const u8 *scriptPubkey UNNEEDED)
|
2019-10-29 18:00:18 +01:00
|
|
|
{ fprintf(stderr, "encode_scriptpubkey_to_addr called!\n"); abort(); }
|
2018-08-09 04:27:20 +02:00
|
|
|
/* Generated stub for fatal */
|
|
|
|
void fatal(const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
2018-11-22 03:17:29 +01:00
|
|
|
/* Generated stub for fromwire_channel_dev_memleak_reply */
|
|
|
|
bool fromwire_channel_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_channel_dev_memleak_reply called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for fromwire_channel_got_commitsig */
|
2020-08-13 19:45:02 +02:00
|
|
|
bool fromwire_channel_got_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct fee_states **fee_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)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "fromwire_channel_got_commitsig called!\n"); abort(); }
|
|
|
|
/* Generated stub for fromwire_channel_got_revoke */
|
2020-05-07 02:54:26 +02:00
|
|
|
bool fromwire_channel_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 changed_htlc **changed UNNEEDED, struct penalty_base **pbase UNNEEDED, struct bitcoin_tx **penalty_tx UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "fromwire_channel_got_revoke called!\n"); abort(); }
|
|
|
|
/* Generated stub for fromwire_channel_offer_htlc_reply */
|
2020-02-21 06:06:58 +01:00
|
|
|
bool fromwire_channel_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u8 **failuremsg UNNEEDED, wirestring **failurestr UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "fromwire_channel_offer_htlc_reply called!\n"); abort(); }
|
|
|
|
/* Generated stub for fromwire_channel_sending_commitsig */
|
2020-08-13 19:45:02 +02:00
|
|
|
bool fromwire_channel_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 changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, struct bitcoin_signature **htlc_sigs UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "fromwire_channel_sending_commitsig called!\n"); abort(); }
|
2018-07-24 08:18:58 +02:00
|
|
|
/* Generated stub for fromwire_connect_peer_connected */
|
2019-10-11 04:52:04 +02:00
|
|
|
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)
|
2018-07-24 08:18:58 +02:00
|
|
|
{ fprintf(stderr, "fromwire_connect_peer_connected called!\n"); abort(); }
|
2019-12-05 00:11:28 +01:00
|
|
|
/* Generated stub for fromwire_custommsg_in */
|
|
|
|
bool fromwire_custommsg_in(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **msg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_custommsg_in called!\n"); abort(); }
|
2020-02-27 04:47:16 +01:00
|
|
|
/* Generated stub for fromwire_gossip_get_stripped_cupdate_reply */
|
|
|
|
bool fromwire_gossip_get_stripped_cupdate_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **stripped_update UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_gossip_get_stripped_cupdate_reply called!\n"); abort(); }
|
2020-07-29 04:03:03 +02:00
|
|
|
/* Generated stub for fromwire_hsm_get_output_scriptpubkey_reply */
|
|
|
|
bool fromwire_hsm_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_hsm_get_output_scriptpubkey_reply called!\n"); abort(); }
|
2018-07-23 04:23:02 +02:00
|
|
|
/* Generated stub for fromwire_hsm_sign_commitment_tx_reply */
|
2018-12-03 00:15:06 +01:00
|
|
|
bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
2018-07-23 04:23:02 +02:00
|
|
|
{ fprintf(stderr, "fromwire_hsm_sign_commitment_tx_reply called!\n"); abort(); }
|
2018-11-22 03:17:29 +01:00
|
|
|
/* Generated stub for fromwire_onchain_dev_memleak_reply */
|
|
|
|
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for get_block_height */
|
|
|
|
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
|
|
|
|
{ fprintf(stderr, "get_block_height called!\n"); abort(); }
|
2019-05-31 09:30:32 +02:00
|
|
|
/* Generated stub for htlc_is_trimmed */
|
|
|
|
bool htlc_is_trimmed(enum side htlc_owner UNNEEDED,
|
|
|
|
struct amount_msat htlc_amount UNNEEDED,
|
|
|
|
u32 feerate_per_kw UNNEEDED,
|
|
|
|
struct amount_sat dust_limit UNNEEDED,
|
2020-08-13 19:44:02 +02:00
|
|
|
enum side side UNNEEDED,
|
|
|
|
bool option_anchor_outputs UNNEEDED)
|
2019-05-31 09:30:32 +02:00
|
|
|
{ fprintf(stderr, "htlc_is_trimmed called!\n"); abort(); }
|
2019-12-12 00:55:45 +01:00
|
|
|
/* Generated stub for htlc_set_add */
|
|
|
|
void htlc_set_add(struct lightningd *ld UNNEEDED,
|
|
|
|
struct htlc_in *hin UNNEEDED,
|
|
|
|
struct amount_msat total_msat UNNEEDED,
|
|
|
|
const struct secret *payment_secret UNNEEDED)
|
|
|
|
{ fprintf(stderr, "htlc_set_add called!\n"); abort(); }
|
2018-02-05 05:09:27 +01:00
|
|
|
/* Generated stub for invoices_create */
|
2018-02-23 02:04:47 +01:00
|
|
|
bool invoices_create(struct invoices *invoices UNNEEDED,
|
|
|
|
struct invoice *pinvoice UNNEEDED,
|
2019-02-21 03:38:35 +01:00
|
|
|
const struct amount_msat *msat TAKES UNNEEDED,
|
2019-06-12 02:38:54 +02:00
|
|
|
const struct json_escape *label TAKES UNNEEDED,
|
2018-02-28 17:26:58 +01:00
|
|
|
u64 expiry UNNEEDED,
|
|
|
|
const char *b11enc UNNEEDED,
|
2018-07-24 20:24:18 +02:00
|
|
|
const char *description UNNEEDED,
|
2019-11-23 01:19:23 +01:00
|
|
|
const u8 *features UNNEEDED,
|
2018-02-28 17:26:58 +01:00
|
|
|
const struct preimage *r UNNEEDED,
|
|
|
|
const struct sha256 *rhash UNNEEDED)
|
2018-02-05 05:09:27 +01:00
|
|
|
{ fprintf(stderr, "invoices_create called!\n"); abort(); }
|
|
|
|
/* Generated stub for invoices_delete */
|
|
|
|
bool invoices_delete(struct invoices *invoices UNNEEDED,
|
2018-02-23 02:04:47 +01:00
|
|
|
struct invoice invoice UNNEEDED)
|
2018-02-05 05:09:27 +01:00
|
|
|
{ fprintf(stderr, "invoices_delete called!\n"); abort(); }
|
2018-02-26 13:37:53 +01:00
|
|
|
/* Generated stub for invoices_delete_expired */
|
|
|
|
void invoices_delete_expired(struct invoices *invoices UNNEEDED,
|
|
|
|
u64 max_expiry_time UNNEEDED)
|
|
|
|
{ fprintf(stderr, "invoices_delete_expired called!\n"); abort(); }
|
2018-02-05 05:09:27 +01:00
|
|
|
/* Generated stub for invoices_find_by_label */
|
2018-02-23 02:04:47 +01:00
|
|
|
bool invoices_find_by_label(struct invoices *invoices UNNEEDED,
|
|
|
|
struct invoice *pinvoice UNNEEDED,
|
2019-06-12 02:38:54 +02:00
|
|
|
const struct json_escape *label UNNEEDED)
|
2018-02-05 05:09:27 +01:00
|
|
|
{ fprintf(stderr, "invoices_find_by_label called!\n"); abort(); }
|
2018-04-25 01:04:33 +02:00
|
|
|
/* Generated stub for invoices_find_by_rhash */
|
|
|
|
bool invoices_find_by_rhash(struct invoices *invoices UNNEEDED,
|
|
|
|
struct invoice *pinvoice UNNEEDED,
|
|
|
|
const struct sha256 *rhash UNNEEDED)
|
|
|
|
{ fprintf(stderr, "invoices_find_by_rhash called!\n"); abort(); }
|
2018-02-05 05:09:27 +01:00
|
|
|
/* Generated stub for invoices_find_unpaid */
|
2018-02-23 02:04:47 +01:00
|
|
|
bool invoices_find_unpaid(struct invoices *invoices UNNEEDED,
|
|
|
|
struct invoice *pinvoice UNNEEDED,
|
|
|
|
const struct sha256 *rhash UNNEEDED)
|
2018-02-05 05:09:27 +01:00
|
|
|
{ fprintf(stderr, "invoices_find_unpaid called!\n"); abort(); }
|
2018-02-20 02:07:30 +01:00
|
|
|
/* Generated stub for invoices_get_details */
|
2018-07-27 12:57:02 +02:00
|
|
|
const struct invoice_details *invoices_get_details(const tal_t *ctx UNNEEDED,
|
|
|
|
struct invoices *invoices UNNEEDED,
|
|
|
|
struct invoice invoice UNNEEDED)
|
2018-02-20 02:07:30 +01:00
|
|
|
{ fprintf(stderr, "invoices_get_details called!\n"); abort(); }
|
2018-02-05 05:09:27 +01:00
|
|
|
/* Generated stub for invoices_iterate */
|
2018-02-24 13:11:14 +01:00
|
|
|
bool invoices_iterate(struct invoices *invoices UNNEEDED,
|
|
|
|
struct invoice_iterator *it UNNEEDED)
|
2018-02-05 05:09:27 +01:00
|
|
|
{ fprintf(stderr, "invoices_iterate called!\n"); abort(); }
|
2018-02-24 13:11:14 +01:00
|
|
|
/* Generated stub for invoices_iterator_deref */
|
2018-07-27 12:57:02 +02:00
|
|
|
const struct invoice_details *invoices_iterator_deref(
|
|
|
|
const tal_t *ctx UNNEEDED, struct invoices *invoices UNNEEDED,
|
|
|
|
const struct invoice_iterator *it UNNEEDED)
|
2018-02-24 13:11:14 +01:00
|
|
|
{ fprintf(stderr, "invoices_iterator_deref called!\n"); abort(); }
|
2018-02-05 05:09:27 +01:00
|
|
|
/* Generated stub for invoices_new */
|
|
|
|
struct invoices *invoices_new(const tal_t *ctx UNNEEDED,
|
|
|
|
struct db *db UNNEEDED,
|
|
|
|
struct timers *timers UNNEEDED)
|
|
|
|
{ fprintf(stderr, "invoices_new called!\n"); abort(); }
|
|
|
|
/* Generated stub for invoices_resolve */
|
|
|
|
void invoices_resolve(struct invoices *invoices UNNEEDED,
|
2018-02-23 02:04:47 +01:00
|
|
|
struct invoice invoice UNNEEDED,
|
2019-02-21 04:45:55 +01:00
|
|
|
struct amount_msat received UNNEEDED)
|
2018-02-05 05:09:27 +01:00
|
|
|
{ fprintf(stderr, "invoices_resolve called!\n"); abort(); }
|
|
|
|
/* Generated stub for invoices_waitany */
|
|
|
|
void invoices_waitany(const tal_t *ctx UNNEEDED,
|
|
|
|
struct invoices *invoices UNNEEDED,
|
|
|
|
u64 lastpay_index UNNEEDED,
|
|
|
|
void (*cb)(const struct invoice * UNNEEDED, void*) UNNEEDED,
|
|
|
|
void *cbarg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "invoices_waitany called!\n"); abort(); }
|
|
|
|
/* Generated stub for invoices_waitone */
|
|
|
|
void invoices_waitone(const tal_t *ctx UNNEEDED,
|
|
|
|
struct invoices *invoices UNNEEDED,
|
2018-02-23 02:04:47 +01:00
|
|
|
struct invoice invoice UNNEEDED,
|
2018-02-05 05:09:27 +01:00
|
|
|
void (*cb)(const struct invoice * UNNEEDED, void*) UNNEEDED,
|
|
|
|
void *cbarg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "invoices_waitone called!\n"); abort(); }
|
2018-11-15 14:08:10 +01:00
|
|
|
/* Generated stub for json_add_address */
|
|
|
|
void json_add_address(struct json_stream *response UNNEEDED, const char *fieldname UNNEEDED,
|
|
|
|
const struct wireaddr *addr UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_address called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_add_address_internal */
|
|
|
|
void json_add_address_internal(struct json_stream *response UNNEEDED,
|
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
const struct wireaddr_internal *addr UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_address_internal called!\n"); abort(); }
|
2019-05-20 07:07:40 +02:00
|
|
|
/* Generated stub for json_add_amount_msat_compat */
|
|
|
|
void json_add_amount_msat_compat(struct json_stream *result UNNEEDED,
|
|
|
|
struct amount_msat msat UNNEEDED,
|
|
|
|
const char *rawfieldname UNNEEDED,
|
|
|
|
const char *msatfieldname)
|
2019-02-21 03:39:21 +01:00
|
|
|
|
2019-05-20 07:07:40 +02:00
|
|
|
{ fprintf(stderr, "json_add_amount_msat_compat called!\n"); abort(); }
|
2019-01-09 16:07:49 +01:00
|
|
|
/* Generated stub for json_add_amount_msat_only */
|
|
|
|
void json_add_amount_msat_only(struct json_stream *result UNNEEDED,
|
|
|
|
const char *msatfieldname UNNEEDED,
|
|
|
|
struct amount_msat msat)
|
|
|
|
|
|
|
|
{ fprintf(stderr, "json_add_amount_msat_only called!\n"); abort(); }
|
2019-05-20 07:07:40 +02:00
|
|
|
/* Generated stub for json_add_amount_sat_compat */
|
|
|
|
void json_add_amount_sat_compat(struct json_stream *result UNNEEDED,
|
|
|
|
struct amount_sat sat UNNEEDED,
|
|
|
|
const char *rawfieldname UNNEEDED,
|
|
|
|
const char *msatfieldname)
|
2019-02-21 03:40:27 +01:00
|
|
|
|
2019-05-20 07:07:40 +02:00
|
|
|
{ fprintf(stderr, "json_add_amount_sat_compat called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_add_bool */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_bool(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
2018-02-12 11:12:55 +01:00
|
|
|
bool value UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_bool called!\n"); abort(); }
|
2018-07-28 07:53:33 +02:00
|
|
|
/* Generated stub for json_add_hex_talarr */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_hex_talarr(struct json_stream *result UNNEEDED,
|
2018-07-28 07:53:33 +02:00
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
const tal_t *data UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_hex_talarr called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_add_log */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_log(struct json_stream *result UNNEEDED,
|
2019-11-18 01:27:15 +01:00
|
|
|
const struct log_book *lr UNNEEDED,
|
|
|
|
const struct node_id *node_id UNNEEDED,
|
|
|
|
enum log_level minlevel UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "json_add_log called!\n"); abort(); }
|
2019-04-08 11:58:32 +02:00
|
|
|
/* Generated stub for json_add_node_id */
|
|
|
|
void json_add_node_id(struct json_stream *response UNNEEDED,
|
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
const struct node_id *id UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_node_id called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_add_num */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
2018-02-12 11:12:55 +01:00
|
|
|
unsigned int value UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_num called!\n"); abort(); }
|
2019-02-21 14:21:28 +01:00
|
|
|
/* Generated stub for json_add_s32 */
|
|
|
|
void json_add_s32(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
|
|
|
int32_t value UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_s32 called!\n"); abort(); }
|
2019-06-08 10:58:31 +02:00
|
|
|
/* Generated stub for json_add_secret */
|
|
|
|
void json_add_secret(struct json_stream *response UNNEEDED,
|
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
const struct secret *secret UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_secret called!\n"); abort(); }
|
2019-08-27 06:20:05 +02:00
|
|
|
/* Generated stub for json_add_sha256 */
|
|
|
|
void json_add_sha256(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
|
|
|
const struct sha256 *hash UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_sha256 called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_add_short_channel_id */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_short_channel_id(struct json_stream *response UNNEEDED,
|
2018-02-12 11:12:55 +01:00
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
const struct short_channel_id *id UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_short_channel_id called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_add_string */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_string(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, const char *value UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "json_add_string called!\n"); abort(); }
|
2019-04-03 21:28:33 +02:00
|
|
|
/* Generated stub for json_add_timeabs */
|
|
|
|
void json_add_timeabs(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
|
|
|
struct timeabs t UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_timeabs called!\n"); abort(); }
|
2019-06-05 07:29:01 +02:00
|
|
|
/* Generated stub for json_add_tx */
|
|
|
|
void json_add_tx(struct json_stream *result UNNEEDED,
|
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
const struct bitcoin_tx *tx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_tx called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_add_txid */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_txid(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
2018-02-12 11:12:55 +01:00
|
|
|
const struct bitcoin_txid *txid UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_txid called!\n"); abort(); }
|
2019-02-21 14:21:28 +01:00
|
|
|
/* Generated stub for json_add_u32 */
|
|
|
|
void json_add_u32(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
|
|
|
uint32_t value UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_u32 called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_add_u64 */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_u64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
2018-02-12 11:12:55 +01:00
|
|
|
uint64_t value UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_u64 called!\n"); abort(); }
|
2018-02-20 21:59:04 +01:00
|
|
|
/* Generated stub for json_add_uncommitted_channel */
|
2018-10-19 03:17:49 +02:00
|
|
|
void json_add_uncommitted_channel(struct json_stream *response UNNEEDED,
|
2018-02-20 21:59:04 +01:00
|
|
|
const struct uncommitted_channel *uc UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_add_uncommitted_channel called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_array_end */
|
2018-11-20 02:46:32 +01:00
|
|
|
void json_array_end(struct json_stream *js UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "json_array_end called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_array_start */
|
2018-11-20 02:46:32 +01:00
|
|
|
void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "json_array_start called!\n"); abort(); }
|
2019-02-07 16:53:15 +01:00
|
|
|
/* Generated stub for json_get_member */
|
|
|
|
const jsmntok_t *json_get_member(const char *buffer UNNEEDED, const jsmntok_t tok[] UNNEEDED,
|
|
|
|
const char *label UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_get_member called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for json_object_end */
|
2018-11-20 02:46:32 +01:00
|
|
|
void json_object_end(struct json_stream *js UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "json_object_end called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_object_start */
|
2018-11-20 02:46:32 +01:00
|
|
|
void json_object_start(struct json_stream *ks UNNEEDED, const char *fieldname UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{ fprintf(stderr, "json_object_start called!\n"); abort(); }
|
2019-01-09 16:12:35 +01:00
|
|
|
/* Generated stub for json_strdup */
|
|
|
|
char *json_strdup(const tal_t *ctx UNNEEDED, const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_strdup called!\n"); abort(); }
|
2018-10-19 03:17:48 +02:00
|
|
|
/* Generated stub for json_stream_success */
|
2018-10-19 03:17:49 +02:00
|
|
|
struct json_stream *json_stream_success(struct command *cmd UNNEEDED)
|
2018-10-19 03:17:48 +02:00
|
|
|
{ fprintf(stderr, "json_stream_success called!\n"); abort(); }
|
2020-03-10 17:54:09 +01:00
|
|
|
/* Generated stub for json_to_node_id */
|
|
|
|
bool json_to_node_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct node_id *id UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_to_node_id called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_to_number */
|
|
|
|
bool json_to_number(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
unsigned int *num UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_to_number called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_to_preimage */
|
|
|
|
bool json_to_preimage(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, struct preimage *preimage UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_to_preimage called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_to_short_channel_id */
|
|
|
|
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct short_channel_id *scid UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
2019-01-09 16:12:35 +01:00
|
|
|
/* Generated stub for json_tok_bin_from_hex */
|
|
|
|
u8 *json_tok_bin_from_hex(const tal_t *ctx UNNEEDED, const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_tok_bin_from_hex called!\n"); abort(); }
|
2018-04-30 14:54:39 +02:00
|
|
|
/* Generated stub for json_tok_channel_id */
|
|
|
|
bool json_tok_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct channel_id *cid UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_tok_channel_id called!\n"); abort(); }
|
2018-12-16 05:49:06 +01:00
|
|
|
/* Generated stub for json_tok_full */
|
|
|
|
const char *json_tok_full(const char *buffer UNNEEDED, const jsmntok_t *t UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_tok_full called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_tok_full_len */
|
|
|
|
int json_tok_full_len(const jsmntok_t *t UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_tok_full_len called!\n"); abort(); }
|
2019-02-07 16:53:15 +01:00
|
|
|
/* Generated stub for json_tok_streq */
|
|
|
|
bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char *str UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_tok_streq called!\n"); abort(); }
|
2018-02-20 21:59:04 +01:00
|
|
|
/* 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(); }
|
2020-04-14 21:01:18 +02:00
|
|
|
/* Generated stub for new_channel_mvt_invoice_hin */
|
|
|
|
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx UNNEEDED,
|
|
|
|
struct htlc_in *hin UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED)
|
|
|
|
{ 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,
|
|
|
|
struct htlc_out *hout UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED)
|
|
|
|
{ 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,
|
|
|
|
struct htlc_in *hin UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED)
|
|
|
|
{ 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,
|
|
|
|
struct htlc_out *hout UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED)
|
|
|
|
{ fprintf(stderr, "new_channel_mvt_routed_hout called!\n"); abort(); }
|
2020-04-15 05:08:06 +02:00
|
|
|
/* Generated stub for new_coin_deposit_sat */
|
|
|
|
struct chain_coin_mvt *new_coin_deposit_sat(const tal_t *ctx UNNEEDED,
|
|
|
|
const char *account_name UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
u32 vout UNNEEDED,
|
|
|
|
u32 blockheight UNNEEDED,
|
2020-04-15 05:40:28 +02:00
|
|
|
struct amount_sat amount UNNEEDED)
|
2020-04-15 05:08:06 +02:00
|
|
|
{ fprintf(stderr, "new_coin_deposit_sat called!\n"); abort(); }
|
2020-04-02 04:55:44 +02:00
|
|
|
/* Generated stub for notify_chain_mvt */
|
|
|
|
void notify_chain_mvt(struct lightningd *ld UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED)
|
|
|
|
{ fprintf(stderr, "notify_chain_mvt called!\n"); abort(); }
|
2020-03-19 00:40:32 +01:00
|
|
|
/* Generated stub for notify_channel_mvt */
|
|
|
|
void notify_channel_mvt(struct lightningd *ld UNNEEDED, const struct channel_coin_mvt *mvt UNNEEDED)
|
|
|
|
{ fprintf(stderr, "notify_channel_mvt called!\n"); abort(); }
|
2018-12-13 13:58:40 +01:00
|
|
|
/* Generated stub for notify_connect */
|
2019-04-08 11:58:32 +02:00
|
|
|
void notify_connect(struct lightningd *ld UNNEEDED, struct node_id *nodeid UNNEEDED,
|
2018-12-13 13:58:40 +01:00
|
|
|
struct wireaddr_internal *addr UNNEEDED)
|
|
|
|
{ fprintf(stderr, "notify_connect called!\n"); abort(); }
|
|
|
|
/* Generated stub for notify_disconnect */
|
2019-04-08 11:58:32 +02:00
|
|
|
void notify_disconnect(struct lightningd *ld UNNEEDED, struct node_id *nodeid UNNEEDED)
|
2018-12-13 13:58:40 +01:00
|
|
|
{ fprintf(stderr, "notify_disconnect called!\n"); abort(); }
|
2019-06-15 18:50:07 +02: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 03:11:01 +01:00
|
|
|
/* 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,
|
|
|
|
enum onion_type failcode UNNEEDED,
|
|
|
|
struct timeabs *resolved_time UNNEEDED)
|
|
|
|
{ fprintf(stderr, "notify_forward_event 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,
|
2020-04-03 03:46:18 +02:00
|
|
|
u32 blockheight UNNEEDED,
|
|
|
|
bool is_replay UNNEEDED)
|
2018-04-16 13:20:45 +02:00
|
|
|
{ fprintf(stderr, "onchaind_funding_spent called!\n"); abort(); }
|
2019-12-05 11:06:28 +01:00
|
|
|
/* Generated stub for onion_decode */
|
|
|
|
struct onion_payload *onion_decode(const tal_t *ctx UNNEEDED,
|
2020-03-04 14:20:59 +01:00
|
|
|
const struct route_step *rs UNNEEDED,
|
2020-04-11 04:52:51 +02:00
|
|
|
const struct pubkey *blinding UNNEEDED,
|
|
|
|
const struct secret *blinding_ss UNNEEDED,
|
2020-03-04 14:20:59 +01:00
|
|
|
u64 *failtlvtype UNNEEDED,
|
|
|
|
size_t *failtlvpos UNNEEDED)
|
2019-12-05 11:06:28 +01:00
|
|
|
{ fprintf(stderr, "onion_decode called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for onion_type_name */
|
|
|
|
const char *onion_type_name(int e UNNEEDED)
|
|
|
|
{ fprintf(stderr, "onion_type_name called!\n"); abort(); }
|
2018-02-26 14:57:13 +01:00
|
|
|
/* Generated stub for outpointfilter_add */
|
|
|
|
void outpointfilter_add(struct outpointfilter *of UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED)
|
|
|
|
{ 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,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED)
|
|
|
|
{ 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(); }
|
2018-03-26 20:30:11 +02:00
|
|
|
/* Generated stub for outpointfilter_remove */
|
|
|
|
void outpointfilter_remove(struct outpointfilter *of UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED)
|
|
|
|
{ fprintf(stderr, "outpointfilter_remove called!\n"); abort(); }
|
2018-07-20 03:14:02 +02:00
|
|
|
/* Generated stub for param */
|
|
|
|
bool param(struct command *cmd UNNEEDED, const char *buffer UNNEEDED,
|
|
|
|
const jsmntok_t params[] UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "param called!\n"); abort(); }
|
2019-12-04 16:26:57 +01:00
|
|
|
/* Generated stub for param_bin_from_hex */
|
|
|
|
struct command_result *param_bin_from_hex(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
u8 **bin UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_bin_from_hex called!\n"); abort(); }
|
2019-10-11 12:23:12 +02:00
|
|
|
/* Generated stub for param_bitcoin_address */
|
|
|
|
struct command_result *param_bitcoin_address(struct command *cmd UNNEEDED,
|
|
|
|
const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED,
|
|
|
|
const jsmntok_t *tok UNNEEDED,
|
|
|
|
const u8 **scriptpubkey UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_bitcoin_address called!\n"); abort(); }
|
2018-12-16 05:50:06 +01:00
|
|
|
/* Generated stub for param_bool */
|
|
|
|
struct command_result *param_bool(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
bool **b UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_bool called!\n"); abort(); }
|
2019-09-30 18:31:27 +02:00
|
|
|
/* Generated stub for param_channel_id */
|
|
|
|
struct command_result *param_channel_id(struct command *cmd UNNEEDED,
|
|
|
|
const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED,
|
|
|
|
const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct channel_id **cid UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_channel_id called!\n"); abort(); }
|
2018-12-16 05:50:06 +01:00
|
|
|
/* 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(); }
|
2019-03-09 21:29:39 +01:00
|
|
|
/* Generated stub for param_msat */
|
|
|
|
struct command_result *param_msat(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct amount_msat **msat UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_msat called!\n"); abort(); }
|
2019-04-08 11:58:32 +02:00
|
|
|
/* Generated stub for param_node_id */
|
|
|
|
struct command_result *param_node_id(struct command *cmd UNNEEDED,
|
2019-09-20 08:58:51 +02:00
|
|
|
const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED,
|
|
|
|
const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct node_id **id UNNEEDED)
|
2019-04-08 11:58:32 +02:00
|
|
|
{ fprintf(stderr, "param_node_id called!\n"); abort(); }
|
2018-12-16 05:50:06 +01:00
|
|
|
/* Generated stub for param_number */
|
|
|
|
struct command_result *param_number(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
unsigned int **num UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_number called!\n"); abort(); }
|
|
|
|
/* Generated stub for param_short_channel_id */
|
|
|
|
struct command_result *param_short_channel_id(struct command *cmd UNNEEDED,
|
|
|
|
const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED,
|
|
|
|
const jsmntok_t *tok UNNEEDED,
|
|
|
|
struct short_channel_id **scid UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_short_channel_id called!\n"); abort(); }
|
2020-01-03 14:08:29 +01:00
|
|
|
/* Generated stub for param_string */
|
|
|
|
struct command_result *param_string(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
|
|
|
const char * buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
|
|
|
const char **str UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_string called!\n"); abort(); }
|
2018-12-16 05:50:06 +01:00
|
|
|
/* Generated stub for param_tok */
|
|
|
|
struct command_result *param_tok(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
|
|
|
const char *buffer UNNEEDED, const jsmntok_t * tok UNNEEDED,
|
|
|
|
const jsmntok_t **out UNNEEDED)
|
|
|
|
{ fprintf(stderr, "param_tok called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for parse_onionpacket */
|
2019-11-29 21:20:18 +01:00
|
|
|
enum onion_type parse_onionpacket(const u8 *src UNNEEDED,
|
|
|
|
const size_t srclen UNNEEDED,
|
|
|
|
struct onionpacket *dest UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "parse_onionpacket called!\n"); abort(); }
|
|
|
|
/* Generated stub for payment_failed */
|
|
|
|
void payment_failed(struct lightningd *ld UNNEEDED, const struct htlc_out *hout UNNEEDED,
|
2020-05-04 09:19:53 +02:00
|
|
|
const char *localfail UNNEEDED, const u8 *failmsg_needs_update UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "payment_failed called!\n"); abort(); }
|
|
|
|
/* Generated stub for payment_store */
|
2020-01-23 00:38:04 +01:00
|
|
|
void payment_store(struct lightningd *ld UNNEEDED, struct wallet_payment *payment UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "payment_store called!\n"); abort(); }
|
|
|
|
/* Generated stub for payment_succeeded */
|
|
|
|
void payment_succeeded(struct lightningd *ld UNNEEDED, struct htlc_out *hout UNNEEDED,
|
|
|
|
const struct preimage *rval UNNEEDED)
|
|
|
|
{ fprintf(stderr, "payment_succeeded called!\n"); abort(); }
|
2019-12-04 16:26:57 +01:00
|
|
|
/* Generated stub for peer_get_owning_subd */
|
|
|
|
struct subd *peer_get_owning_subd(struct peer *peer UNNEEDED)
|
|
|
|
{ fprintf(stderr, "peer_get_owning_subd called!\n"); abort(); }
|
2018-11-22 03:17:29 +01:00
|
|
|
/* Generated stub for peer_memleak_done */
|
|
|
|
void peer_memleak_done(struct command *cmd UNNEEDED, struct subd *leaker UNNEEDED)
|
|
|
|
{ fprintf(stderr, "peer_memleak_done called!\n"); abort(); }
|
2018-02-20 21:59:09 +01:00
|
|
|
/* Generated stub for peer_start_channeld */
|
2018-08-09 02:26:30 +02:00
|
|
|
void peer_start_channeld(struct channel *channel UNNEEDED,
|
2019-06-03 20:11:25 +02:00
|
|
|
struct per_peer_state *pps UNNEEDED,
|
2018-02-20 21:59:09 +01:00
|
|
|
const u8 *funding_signed UNNEEDED,
|
|
|
|
bool reconnected UNNEEDED)
|
|
|
|
{ fprintf(stderr, "peer_start_channeld called!\n"); abort(); }
|
2018-02-20 21:59:09 +01:00
|
|
|
/* Generated stub for peer_start_closingd */
|
|
|
|
void peer_start_closingd(struct channel *channel UNNEEDED,
|
2019-06-03 20:11:25 +02:00
|
|
|
struct per_peer_state *pps UNNEEDED,
|
2018-04-23 12:08:02 +02:00
|
|
|
bool reconnected UNNEEDED,
|
|
|
|
const u8 *channel_reestablish UNNEEDED)
|
2018-02-20 21:59:09 +01:00
|
|
|
{ fprintf(stderr, "peer_start_closingd 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 16:10:58 +02:00
|
|
|
/* Generated stub for peer_start_openingd */
|
|
|
|
void peer_start_openingd(struct peer *peer UNNEEDED,
|
2019-06-03 20:11:25 +02:00
|
|
|
struct per_peer_state *pps 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 16:10:58 +02:00
|
|
|
const u8 *msg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "peer_start_openingd called!\n"); abort(); }
|
2019-06-03 20:11:25 +02:00
|
|
|
/* Generated stub for per_peer_state_set_fds */
|
|
|
|
void per_peer_state_set_fds(struct per_peer_state *pps UNNEEDED,
|
|
|
|
int peer_fd UNNEEDED, int gossip_fd UNNEEDED, int gossip_store_fd UNNEEDED)
|
|
|
|
{ fprintf(stderr, "per_peer_state_set_fds called!\n"); abort(); }
|
2019-01-19 15:56:05 +01:00
|
|
|
/* Generated stub for plugin_hook_call_ */
|
2020-05-05 03:11:59 +02:00
|
|
|
bool plugin_hook_call_(struct lightningd *ld UNNEEDED, const struct plugin_hook *hook UNNEEDED,
|
2020-05-04 09:19:53 +02:00
|
|
|
tal_t *cb_arg STEALS UNNEEDED)
|
2019-01-19 15:56:05 +01:00
|
|
|
{ fprintf(stderr, "plugin_hook_call_ called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for process_onionpacket */
|
|
|
|
struct route_step *process_onionpacket(
|
|
|
|
const tal_t * ctx UNNEEDED,
|
|
|
|
const struct onionpacket *packet UNNEEDED,
|
2020-01-23 06:54:10 +01:00
|
|
|
const struct secret *shared_secret UNNEEDED,
|
2018-09-03 03:08:53 +02:00
|
|
|
const u8 *assocdata UNNEEDED,
|
2020-03-12 00:59:01 +01:00
|
|
|
const size_t assocdatalen UNNEEDED,
|
|
|
|
bool has_realm
|
2018-09-03 03:08:53 +02:00
|
|
|
)
|
|
|
|
{ fprintf(stderr, "process_onionpacket called!\n"); abort(); }
|
|
|
|
/* Generated stub for serialize_onionpacket */
|
|
|
|
u8 *serialize_onionpacket(
|
|
|
|
const tal_t *ctx UNNEEDED,
|
|
|
|
const struct onionpacket *packet UNNEEDED)
|
|
|
|
{ fprintf(stderr, "serialize_onionpacket called!\n"); abort(); }
|
2018-02-12 11:13:04 +01:00
|
|
|
/* Generated stub for subd_release_channel */
|
2018-02-18 13:59:46 +01:00
|
|
|
void subd_release_channel(struct subd *owner UNNEEDED, void *channel UNNEEDED)
|
2018-02-12 11:13:04 +01:00
|
|
|
{ fprintf(stderr, "subd_release_channel called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for subd_req_ */
|
|
|
|
void subd_req_(const tal_t *ctx UNNEEDED,
|
|
|
|
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,
|
|
|
|
void *replycb_data UNNEEDED)
|
|
|
|
{ fprintf(stderr, "subd_req_ called!\n"); abort(); }
|
|
|
|
/* 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(); }
|
2020-04-11 05:22:40 +02:00
|
|
|
/* Generated stub for subkey_from_hmac */
|
|
|
|
void subkey_from_hmac(const char *prefix UNNEEDED,
|
|
|
|
const struct secret *base UNNEEDED,
|
|
|
|
struct secret *key UNNEEDED)
|
|
|
|
{ fprintf(stderr, "subkey_from_hmac called!\n"); abort(); }
|
2019-08-10 12:48:13 +02:00
|
|
|
/* Generated stub for topology_add_sync_waiter_ */
|
|
|
|
void topology_add_sync_waiter_(const tal_t *ctx UNNEEDED,
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
|
|
|
void (*cb)(struct chain_topology *topo UNNEEDED,
|
|
|
|
void *arg) UNNEEDED,
|
|
|
|
void *arg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "topology_add_sync_waiter_ called!\n"); abort(); }
|
2018-11-22 03:17:29 +01:00
|
|
|
/* Generated stub for towire_channel_dev_memleak */
|
|
|
|
u8 *towire_channel_dev_memleak(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_dev_memleak called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for towire_channel_dev_reenable_commit */
|
|
|
|
u8 *towire_channel_dev_reenable_commit(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_dev_reenable_commit called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for towire_channel_disabled */
|
|
|
|
u8 *towire_channel_disabled(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_disabled called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for towire_channel_fail_htlc */
|
2020-02-18 00:58:58 +01:00
|
|
|
u8 *towire_channel_fail_htlc(const tal_t *ctx UNNEEDED, const struct failed_htlc *failed_htlc UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "towire_channel_fail_htlc called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_channel_fulfill_htlc */
|
|
|
|
u8 *towire_channel_fulfill_htlc(const tal_t *ctx UNNEEDED, const struct fulfilled_htlc *fulfilled_htlc UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_fulfill_htlc called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_channel_got_commitsig_reply */
|
|
|
|
u8 *towire_channel_got_commitsig_reply(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_got_commitsig_reply called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_channel_got_revoke_reply */
|
|
|
|
u8 *towire_channel_got_revoke_reply(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_got_revoke_reply called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_channel_offer_htlc */
|
2020-04-11 05:22:40 +02:00
|
|
|
u8 *towire_channel_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 *blinding UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "towire_channel_offer_htlc called!\n"); abort(); }
|
2020-01-09 16:38:12 +01:00
|
|
|
/* Generated stub for towire_channel_send_shutdown */
|
|
|
|
u8 *towire_channel_send_shutdown(const tal_t *ctx UNNEEDED, const u8 *shutdown_scriptpubkey UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_send_shutdown called!\n"); abort(); }
|
2020-03-10 17:54:09 +01:00
|
|
|
/* Generated stub for towire_channel_sending_commitsig_reply */
|
|
|
|
u8 *towire_channel_sending_commitsig_reply(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_sending_commitsig_reply called!\n"); abort(); }
|
2019-03-09 21:29:39 +01:00
|
|
|
/* Generated stub for towire_channel_specific_feerates */
|
|
|
|
u8 *towire_channel_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_channel_specific_feerates called!\n"); abort(); }
|
2018-08-09 02:25:29 +02:00
|
|
|
/* Generated stub for towire_connectctl_connect_to_peer */
|
2019-04-08 11:58:32 +02:00
|
|
|
u8 *towire_connectctl_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED)
|
2018-08-09 02:25:29 +02:00
|
|
|
{ fprintf(stderr, "towire_connectctl_connect_to_peer called!\n"); abort(); }
|
2018-07-24 08:18:58 +02:00
|
|
|
/* Generated stub for towire_connectctl_peer_disconnected */
|
2019-04-08 11:58:32 +02:00
|
|
|
u8 *towire_connectctl_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
2018-07-24 08:18:58 +02:00
|
|
|
{ fprintf(stderr, "towire_connectctl_peer_disconnected called!\n"); abort(); }
|
2019-12-04 16:26:57 +01:00
|
|
|
/* Generated stub for towire_custommsg_out */
|
|
|
|
u8 *towire_custommsg_out(const tal_t *ctx UNNEEDED, const u8 *msg UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_custommsg_out called!\n"); abort(); }
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Generated stub for towire_errorfmt */
|
|
|
|
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
|
|
|
const struct channel_id *channel UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for towire_expiry_too_far */
|
|
|
|
u8 *towire_expiry_too_far(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_expiry_too_far called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_expiry_too_soon */
|
|
|
|
u8 *towire_expiry_too_soon(const tal_t *ctx UNNEEDED, const u8 *channel_update UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_expiry_too_soon called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_fee_insufficient */
|
|
|
|
u8 *towire_fee_insufficient(const tal_t *ctx UNNEEDED, struct amount_msat htlc_msat UNNEEDED, const u8 *channel_update UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_fee_insufficient called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_final_incorrect_cltv_expiry */
|
|
|
|
u8 *towire_final_incorrect_cltv_expiry(const tal_t *ctx UNNEEDED, u32 cltv_expiry UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_final_incorrect_cltv_expiry called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_final_incorrect_htlc_amount */
|
|
|
|
u8 *towire_final_incorrect_htlc_amount(const tal_t *ctx UNNEEDED, struct amount_msat incoming_htlc_amt UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_final_incorrect_htlc_amount called!\n"); abort(); }
|
2020-02-27 04:47:16 +01:00
|
|
|
/* Generated stub for towire_gossip_get_stripped_cupdate */
|
|
|
|
u8 *towire_gossip_get_stripped_cupdate(const tal_t *ctx UNNEEDED, const struct short_channel_id *channel_id UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_gossip_get_stripped_cupdate called!\n"); abort(); }
|
2020-07-29 04:03:03 +02:00
|
|
|
/* Generated stub for towire_hsm_get_output_scriptpubkey */
|
|
|
|
u8 *towire_hsm_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_hsm_get_output_scriptpubkey called!\n"); abort(); }
|
2018-07-23 04:23:02 +02:00
|
|
|
/* Generated stub for towire_hsm_sign_commitment_tx */
|
2020-05-27 03:37:44 +02:00
|
|
|
u8 *towire_hsm_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)
|
2018-07-23 04:23:02 +02:00
|
|
|
{ fprintf(stderr, "towire_hsm_sign_commitment_tx called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for towire_incorrect_cltv_expiry */
|
|
|
|
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx UNNEEDED, u32 cltv_expiry UNNEEDED, const u8 *channel_update UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_incorrect_cltv_expiry called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_incorrect_or_unknown_payment_details */
|
|
|
|
u8 *towire_incorrect_or_unknown_payment_details(const tal_t *ctx UNNEEDED, struct amount_msat htlc_msat UNNEEDED, u32 height UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_incorrect_or_unknown_payment_details called!\n"); abort(); }
|
2020-03-04 14:20:59 +01:00
|
|
|
/* Generated stub for towire_invalid_onion_payload */
|
2020-07-07 22:50:21 +02:00
|
|
|
u8 *towire_invalid_onion_payload(const tal_t *ctx UNNEEDED, bigsize type UNNEEDED, u16 offset UNNEEDED)
|
2020-03-04 14:20:59 +01:00
|
|
|
{ fprintf(stderr, "towire_invalid_onion_payload called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for towire_invalid_realm */
|
|
|
|
u8 *towire_invalid_realm(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_invalid_realm called!\n"); abort(); }
|
2018-11-22 03:17:29 +01:00
|
|
|
/* Generated stub for towire_onchain_dev_memleak */
|
|
|
|
u8 *towire_onchain_dev_memleak(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_onchain_dev_memleak called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for towire_onchain_known_preimage */
|
2020-04-03 03:46:18 +02:00
|
|
|
u8 *towire_onchain_known_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED, bool is_replay UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "towire_onchain_known_preimage called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for towire_permanent_channel_failure */
|
|
|
|
u8 *towire_permanent_channel_failure(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_permanent_channel_failure called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_permanent_node_failure */
|
|
|
|
u8 *towire_permanent_node_failure(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_permanent_node_failure called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_required_channel_feature_missing */
|
|
|
|
u8 *towire_required_channel_feature_missing(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_required_channel_feature_missing called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_required_node_feature_missing */
|
|
|
|
u8 *towire_required_node_feature_missing(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_required_node_feature_missing called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_temporary_channel_failure */
|
|
|
|
u8 *towire_temporary_channel_failure(const tal_t *ctx UNNEEDED, const u8 *channel_update UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_temporary_channel_failure called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_temporary_node_failure */
|
|
|
|
u8 *towire_temporary_node_failure(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_temporary_node_failure called!\n"); abort(); }
|
|
|
|
/* Generated stub for towire_unknown_next_peer */
|
|
|
|
u8 *towire_unknown_next_peer(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "towire_unknown_next_peer called!\n"); abort(); }
|
2018-02-20 21:59:09 +01:00
|
|
|
/* Generated stub for watch_txid */
|
|
|
|
struct txwatch *watch_txid(const tal_t *ctx UNNEEDED,
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
2018-08-13 05:05:33 +02:00
|
|
|
enum watch_result (*cb)(struct lightningd *ld UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED,
|
|
|
|
const struct bitcoin_txid * UNNEEDED,
|
2019-06-28 03:58:31 +02:00
|
|
|
const struct bitcoin_tx * UNNEEDED,
|
2018-02-20 21:59:09 +01:00
|
|
|
unsigned int depth))
|
|
|
|
{ fprintf(stderr, "watch_txid called!\n"); abort(); }
|
|
|
|
/* Generated stub for watch_txo */
|
|
|
|
struct txowatch *watch_txo(const tal_t *ctx UNNEEDED,
|
|
|
|
struct chain_topology *topo UNNEEDED,
|
|
|
|
struct channel *channel UNNEEDED,
|
|
|
|
const struct bitcoin_txid *txid UNNEEDED,
|
|
|
|
unsigned int output UNNEEDED,
|
|
|
|
enum watch_result (*cb)(struct channel *channel UNNEEDED,
|
|
|
|
const struct bitcoin_tx *tx UNNEEDED,
|
|
|
|
size_t input_num UNNEEDED,
|
|
|
|
const struct block *block))
|
|
|
|
{ fprintf(stderr, "watch_txo called!\n"); abort(); }
|
2019-12-04 16:53:12 +01:00
|
|
|
/* Generated stub for wire_type_is_defined */
|
|
|
|
bool wire_type_is_defined(u16 type UNNEEDED)
|
|
|
|
{ fprintf(stderr, "wire_type_is_defined called!\n"); abort(); }
|
|
|
|
/* Generated stub for wire_type_name */
|
|
|
|
const char *wire_type_name(int e UNNEEDED)
|
|
|
|
{ fprintf(stderr, "wire_type_name called!\n"); abort(); }
|
2020-02-18 00:58:58 +01:00
|
|
|
/* Generated stub for wrap_onionreply */
|
|
|
|
struct onionreply *wrap_onionreply(const tal_t *ctx UNNEEDED,
|
|
|
|
const struct secret *shared_secret UNNEEDED,
|
|
|
|
const struct onionreply *reply UNNEEDED)
|
|
|
|
{ fprintf(stderr, "wrap_onionreply called!\n"); abort(); }
|
2017-12-12 04:42:38 +01:00
|
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
#if DEVELOPER
|
|
|
|
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "dev_disconnect_permanent called!\n"); abort(); }
|
|
|
|
#endif
|
|
|
|
|
2018-07-23 04:23:03 +02:00
|
|
|
/* Fake stubs to talk to hsm */
|
2019-04-08 11:58:32 +02:00
|
|
|
u8 *towire_hsm_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
|
2018-07-23 04:23:03 +02:00
|
|
|
{
|
|
|
|
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 03:40:32 +01:00
|
|
|
{
|
|
|
|
}
|
2018-07-23 04:23:03 +02:00
|
|
|
bool fromwire_hsm_get_channel_basepoints_reply(const void *p UNNEEDED,
|
|
|
|
struct basepoints *basepoints,
|
|
|
|
struct pubkey *funding_pubkey)
|
|
|
|
{
|
|
|
|
struct secret empty;
|
|
|
|
memset(&empty, 0, sizeof(empty));
|
|
|
|
pubkey_from_secret(&empty, funding_pubkey);
|
|
|
|
pubkey_from_secret(&empty, &basepoints->revocation);
|
|
|
|
pubkey_from_secret(&empty, &basepoints->payment);
|
|
|
|
pubkey_from_secret(&empty, &basepoints->htlc);
|
|
|
|
pubkey_from_secret(&empty, &basepoints->delayed_payment);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-01 02:10:48 +01:00
|
|
|
static char *wallet_err;
|
2018-08-09 04:27:20 +02:00
|
|
|
static void wallet_test_fatal(const char *fmt, ...)
|
2017-11-01 02:10:48 +01:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
/* Fail hard if we're complaining about not being in transaction */
|
|
|
|
assert(!strstarts(fmt, "No longer in transaction"));
|
|
|
|
|
2017-11-01 02:21:56 +01:00
|
|
|
/* Fail hard if we're complaining about not being in transaction */
|
|
|
|
assert(!strstarts(fmt, "No longer in transaction"));
|
|
|
|
|
2017-11-01 02:10:48 +01:00
|
|
|
va_start(ap, fmt);
|
|
|
|
wallet_err = tal_vfmt(NULL, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2017-11-01 02:10:48 +01:00
|
|
|
#define transaction_wrap(db, ...) \
|
2017-11-01 02:21:56 +01:00
|
|
|
(db_begin_transaction(db), __VA_ARGS__, db_commit_transaction(db), wallet_err == NULL)
|
2017-11-01 02:10:48 +01:00
|
|
|
|
2019-11-17 12:41:33 +01:00
|
|
|
struct log *new_log(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 11:12:55 +01:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-11-18 01:27:17 +01:00
|
|
|
struct log_book *new_log_book(struct lightningd *ld UNNEEDED, size_t max_mem UNNEEDED)
|
2018-02-12 11:12:55 +01:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:06:07 +01:00
|
|
|
void txfilter_add_scriptpubkey(struct txfilter *filter UNNEEDED, const u8 *script TAKES)
|
|
|
|
{
|
|
|
|
if (taken(script))
|
|
|
|
tal_free(script);
|
|
|
|
}
|
|
|
|
|
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 11:12:55 +01:00
|
|
|
static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx)
|
2017-08-05 14:52:39 +02:00
|
|
|
{
|
2019-09-03 21:10:29 +02:00
|
|
|
char *dsn, *filename = tal_fmt(ctx, "/tmp/ldb-XXXXXX");
|
2017-08-05 14:52:39 +02:00
|
|
|
int fd = mkstemp(filename);
|
|
|
|
struct wallet *w = tal(ctx, struct wallet);
|
2018-03-07 01:06:07 +01:00
|
|
|
static unsigned char badseed[BIP32_ENTROPY_LEN_128];
|
2020-07-29 03:20:30 +02: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);
|
|
|
|
w->db = db_open(w, dsn);
|
|
|
|
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-01-17 21:29:49 +01:00
|
|
|
list_head_init(&w->unstored_payments);
|
2018-02-12 11:12:55 +01:00
|
|
|
w->ld = ld;
|
2018-03-07 01:06:07 +01:00
|
|
|
ld->wallet = w;
|
|
|
|
|
|
|
|
w->bip32_base = tal(w, struct ext_key);
|
|
|
|
CHECK(bip32_key_from_seed(badseed, sizeof(badseed),
|
|
|
|
BIP32_VER_TEST_PRIVATE, 0,
|
|
|
|
w->bip32_base) == WALLY_OK);
|
2017-09-26 14:43:09 +02:00
|
|
|
|
2018-01-02 05:03:42 +01:00
|
|
|
CHECK_MSG(w->db, "Failed opening the db");
|
2019-12-18 18:57:37 +01:00
|
|
|
db_begin_transaction(w->db);
|
2020-07-29 03:20:30 +02:00
|
|
|
db_migrate(ld, w->db, bip32_base);
|
2019-12-18 19:45:24 +01:00
|
|
|
w->db->data_version = 0;
|
2019-12-18 18:57:37 +01:00
|
|
|
db_commit_transaction(w->db);
|
2018-01-02 05:03:42 +01:00
|
|
|
CHECK_MSG(!wallet_err, "DB migration failed");
|
2018-02-18 13:53:46 +01:00
|
|
|
w->max_channel_dbid = 0;
|
2018-01-02 05:03:42 +01:00
|
|
|
|
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 11:58:32 +02:00
|
|
|
struct node_id id;
|
2019-02-21 04:45:55 +01:00
|
|
|
struct amount_sat fee_estimate, change_satoshis;
|
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 03:39:51 +01:00
|
|
|
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 11:58:32 +02:00
|
|
|
node_id_from_pubkey(&id, &pk);
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2017-11-01 02:21:56 +01:00
|
|
|
db_begin_transaction(w->db);
|
|
|
|
|
2017-05-31 15:26:30 +02:00
|
|
|
/* Should work, it's the first time we add it */
|
2017-05-31 16:16:59 +02:00
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, p2sh_wpkh),
|
|
|
|
"wallet_add_utxo failed on first add");
|
2017-05-31 15:26:30 +02:00
|
|
|
|
|
|
|
/* Should fail, we already have that UTXO */
|
2017-05-31 16:16:59 +02:00
|
|
|
CHECK_MSG(!wallet_add_utxo(w, &u, p2sh_wpkh),
|
|
|
|
"wallet_add_utxo succeeded on second add");
|
|
|
|
|
2018-02-08 22:43:01 +01:00
|
|
|
/* Attempt to save an UTXO with close_info set */
|
2017-12-20 12:44:00 +01:00
|
|
|
memset(&u.txid, 1, sizeof(u.txid));
|
|
|
|
u.close_info = tal(w, struct unilateral_close_info);
|
|
|
|
u.close_info->channel_id = 42;
|
2019-04-08 11:58:32 +02:00
|
|
|
u.close_info->peer_id = id;
|
2019-09-10 04:24:27 +02:00
|
|
|
u.close_info->commitment_point = &pk;
|
2020-07-29 04:08:17 +02:00
|
|
|
/* Arbitrarily set scriptpubkey len to 20 */
|
|
|
|
u.scriptPubkey = tal_arr(w, u8, 20);
|
|
|
|
memset(u.scriptPubkey, 1, 20);
|
2017-12-20 12:44:00 +01:00
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, p2sh_wpkh),
|
|
|
|
"wallet_add_utxo with close_info");
|
|
|
|
|
|
|
|
/* Now select them */
|
2019-08-30 04:13:33 +02:00
|
|
|
utxos = wallet_select_coins(w, w, true, AMOUNT_SAT(2), 0, 21,
|
2019-02-21 20:13:20 +01:00
|
|
|
0 /* no confirmations required */,
|
|
|
|
&fee_estimate, &change_satoshis);
|
2017-12-20 12:44:00 +01:00
|
|
|
CHECK(utxos && tal_count(utxos) == 2);
|
|
|
|
|
|
|
|
u = *utxos[1];
|
|
|
|
CHECK(u.close_info->channel_id == 42 &&
|
2019-09-10 04:24:27 +02:00
|
|
|
pubkey_eq(u.close_info->commitment_point, &pk) &&
|
2019-04-08 11:58:32 +02:00
|
|
|
node_id_eq(&u.close_info->peer_id, &id));
|
2017-12-20 12:44:00 +01:00
|
|
|
/* Now un-reserve them for the tests below */
|
|
|
|
tal_free(utxos);
|
|
|
|
|
|
|
|
|
2017-05-31 16:16:59 +02:00
|
|
|
/* Attempt to reserve the utxo */
|
|
|
|
CHECK_MSG(wallet_update_output_status(w, &u.txid, u.outnum,
|
|
|
|
output_state_available,
|
|
|
|
output_state_reserved),
|
|
|
|
"could not reserve available output");
|
|
|
|
|
|
|
|
/* Reserving twice should fail */
|
|
|
|
CHECK_MSG(!wallet_update_output_status(w, &u.txid, u.outnum,
|
|
|
|
output_state_available,
|
|
|
|
output_state_reserved),
|
|
|
|
"could reserve already reserved output");
|
|
|
|
|
|
|
|
/* Un-reserving should work */
|
|
|
|
CHECK_MSG(wallet_update_output_status(w, &u.txid, u.outnum,
|
|
|
|
output_state_reserved,
|
|
|
|
output_state_available),
|
|
|
|
"could not unreserve reserved output");
|
|
|
|
|
|
|
|
/* Switching from any to something else */
|
|
|
|
CHECK_MSG(wallet_update_output_status(w, &u.txid, u.outnum,
|
|
|
|
output_state_any,
|
|
|
|
output_state_spent),
|
|
|
|
"could not change output state ignoring oldstate");
|
|
|
|
|
2019-09-10 04:24:27 +02:00
|
|
|
/* Attempt to save an UTXO with close_info set, no commitment_point */
|
|
|
|
memset(&u.txid, 2, sizeof(u.txid));
|
|
|
|
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;
|
2020-07-29 04:08:17 +02:00
|
|
|
u.scriptPubkey = tal_arr(w, u8, 20);
|
|
|
|
memset(u.scriptPubkey, 1, 20);
|
2019-09-10 04:24:27 +02:00
|
|
|
CHECK_MSG(wallet_add_utxo(w, &u, p2sh_wpkh),
|
|
|
|
"wallet_add_utxo with close_info no commitment_point");
|
|
|
|
|
|
|
|
/* Now select it */
|
2019-08-30 04:13:33 +02:00
|
|
|
utxos = wallet_select_coins(w, w, true, AMOUNT_SAT(5), 0, 21,
|
2019-09-10 04:24:27 +02:00
|
|
|
0 /* no confirmations required */,
|
|
|
|
&fee_estimate, &change_satoshis);
|
|
|
|
CHECK(utxos && tal_count(utxos) == 2);
|
|
|
|
|
|
|
|
u = *utxos[1];
|
|
|
|
CHECK(u.close_info->channel_id == 42 &&
|
|
|
|
u.close_info->commitment_point == NULL &&
|
|
|
|
node_id_eq(&u.close_info->peer_id, &id));
|
|
|
|
/* Now un-reserve them */
|
|
|
|
tal_free(utxos);
|
|
|
|
|
2017-11-01 02:21:56 +01:00
|
|
|
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 13:17:58 +02:00
|
|
|
struct secret secret;
|
2017-08-18 06:43:53 +02:00
|
|
|
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 02:21:56 +01:00
|
|
|
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 06:43:53 +02:00
|
|
|
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 13:17:58 +02:00
|
|
|
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 02:21:56 +01:00
|
|
|
|
|
|
|
db_commit_transaction(w->db);
|
|
|
|
CHECK(!wallet_err);
|
2017-07-18 19:03:05 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-08-18 06:43:52 +02:00
|
|
|
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);
|
2018-07-28 08:00:16 +02:00
|
|
|
eq = memeq(lin1, tal_count(lin1), lin2, tal_count(lin2));
|
2017-08-18 06:43:52 +02:00
|
|
|
tal_free(lin1);
|
|
|
|
return eq;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
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 02:06:12 +01:00
|
|
|
struct channel_info *ci1 = &c1->channel_info, *ci2 = &c2->channel_info;
|
2018-02-12 11:12:55 +01:00
|
|
|
struct changed_htlc *lc1 = c1->last_sent_commit, *lc2 = c2->last_sent_commit;
|
|
|
|
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 11:12:55 +01:00
|
|
|
CHECK(c1->peer == c2->peer);
|
|
|
|
CHECK(c1->their_shachain.id == c2->their_shachain.id);
|
2019-04-08 11:58:32 +02:00
|
|
|
CHECK_MSG(node_id_eq(&p1->id, &p2->id), "NodeIDs do not match");
|
2018-07-04 07:30:02 +02:00
|
|
|
CHECK((c1->scid == NULL && c2->scid == NULL)
|
|
|
|
|| short_channel_id_eq(c1->scid, c2->scid));
|
2019-02-21 04:45:55 +01:00
|
|
|
CHECK(amount_msat_eq(c1->our_msat, c2->our_msat));
|
2019-09-29 09:35:45 +02:00
|
|
|
CHECK((c1->shutdown_scriptpubkey[REMOTE] == NULL && c2->shutdown_scriptpubkey[REMOTE] == NULL) || memeq(
|
|
|
|
c1->shutdown_scriptpubkey[REMOTE],
|
|
|
|
tal_count(c1->shutdown_scriptpubkey[REMOTE]),
|
|
|
|
c2->shutdown_scriptpubkey[REMOTE],
|
|
|
|
tal_count(c2->shutdown_scriptpubkey[REMOTE])));
|
2018-02-19 02:06:12 +01:00
|
|
|
CHECK(memeq(
|
|
|
|
&c1->funding_txid,
|
2017-08-05 12:28:44 +02:00
|
|
|
sizeof(struct sha256_double),
|
2018-02-19 02:06:12 +01:00
|
|
|
&c2->funding_txid,
|
2017-08-05 12:28:44 +02:00
|
|
|
sizeof(struct sha256_double)));
|
2018-02-19 02:06:12 +01:00
|
|
|
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);
|
2019-09-09 18:11:24 +02:00
|
|
|
CHECK(fee_states_valid(ci1->fee_states, c1->opener));
|
|
|
|
CHECK(fee_states_valid(ci2->fee_states, c2->opener));
|
2019-12-12 18:18:25 +01:00
|
|
|
for (enum htlc_state i = 0; i < ARRAY_SIZE(ci1->fee_states->feerate);
|
|
|
|
i++) {
|
|
|
|
if (ci1->fee_states->feerate[i] == NULL) {
|
|
|
|
CHECK(ci2->fee_states->feerate[i] == NULL);
|
|
|
|
} else {
|
|
|
|
CHECK(*ci1->fee_states->feerate[i]
|
|
|
|
== *ci2->fee_states->feerate[i]);
|
|
|
|
}
|
|
|
|
}
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
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 09:02:35 +02:00
|
|
|
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 11:12:55 +01:00
|
|
|
CHECK((c1->last_tx != NULL) == (c2->last_tx != NULL));
|
2020-01-05 16:52:34 +01:00
|
|
|
if (c1->last_tx) {
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK(bitcoin_tx_eq(c1->last_tx, c2->last_tx));
|
2017-08-18 06:43:52 +02:00
|
|
|
}
|
2018-02-19 02:06:12 +01:00
|
|
|
CHECK(memeq(&c1->last_sig, sizeof(c1->last_sig),
|
|
|
|
&c2->last_sig, sizeof(c2->last_sig)));
|
2017-08-18 06:43:52 +02:00
|
|
|
|
2018-03-07 01:06:07 +01:00
|
|
|
CHECK(c1->final_key_idx == c2->final_key_idx);
|
2019-09-29 09:35:45 +02:00
|
|
|
CHECK(memeq(c1->shutdown_scriptpubkey[REMOTE],
|
|
|
|
tal_count(c1->shutdown_scriptpubkey[REMOTE]),
|
|
|
|
c2->shutdown_scriptpubkey[REMOTE],
|
|
|
|
tal_count(c2->shutdown_scriptpubkey[REMOTE])));
|
2017-11-26 00:06:33 +01:00
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK(c1->last_was_revoke == c2->last_was_revoke);
|
2018-01-13 14:25:49 +01:00
|
|
|
|
2017-08-05 12:28:44 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
static struct channel *wallet_channel_load(struct wallet *w, const u64 dbid)
|
2018-01-03 06:25:30 +01:00
|
|
|
{
|
|
|
|
struct peer *peer;
|
2018-02-12 11:12:55 +01:00
|
|
|
struct channel *channel;
|
2018-01-03 06:25:30 +01:00
|
|
|
|
|
|
|
/* We expect only one peer, but reuse same code */
|
2019-08-09 18:01:31 +02:00
|
|
|
if (!wallet_init_channels(w))
|
2018-01-03 06:25:30 +01:00
|
|
|
return NULL;
|
2018-02-12 11:12:55 +01:00
|
|
|
peer = list_top(&w->ld->peers, struct peer, list);
|
2018-01-03 06:25:30 +01:00
|
|
|
CHECK(peer);
|
2018-02-12 11:12:55 +01:00
|
|
|
|
|
|
|
/* 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 06:25:30 +01:00
|
|
|
}
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-08-05 12:28:44 +02:00
|
|
|
{
|
2018-02-12 11:12:55 +01:00
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
|
|
|
struct channel c1, *c2 = tal(w, struct channel);
|
2018-10-26 08:01:26 +02:00
|
|
|
struct wireaddr_internal addr;
|
2018-02-12 11:12:55 +01:00
|
|
|
struct peer *p;
|
2018-02-19 02:06:12 +01:00
|
|
|
struct channel_info *ci = &c1.channel_info;
|
2017-12-18 07:41:52 +01:00
|
|
|
struct bitcoin_txid *hash = tal(w, struct bitcoin_txid);
|
2017-08-05 12:28:44 +02:00
|
|
|
struct pubkey pk;
|
2019-04-08 11:58:32 +02:00
|
|
|
struct node_id id;
|
2018-09-04 09:02:35 +02:00
|
|
|
struct changed_htlc *last_commit;
|
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-01 20:17:31 +02: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;
|
2019-12-12 18:18:25 +01:00
|
|
|
u32 feerate;
|
2019-05-01 20:17:31 +02:00
|
|
|
bool load;
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
memset(&c1, 0, sizeof(c1));
|
|
|
|
memset(c2, 0, sizeof(*c2));
|
2018-02-19 02:06:12 +01:00
|
|
|
memset(ci, 3, sizeof(*ci));
|
2017-10-31 00:11:37 +01:00
|
|
|
mempat(hash, sizeof(*hash));
|
|
|
|
mempat(sig, sizeof(*sig));
|
2019-05-01 20:17:31 +02:00
|
|
|
mempat(node_sig1, sizeof(*node_sig1));
|
|
|
|
mempat(bitcoin_sig1, sizeof(*bitcoin_sig1));
|
2018-09-04 09:02:35 +02:00
|
|
|
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 11:58:32 +02:00
|
|
|
node_id_from_pubkey(&id, &pk);
|
2019-12-12 18:18:25 +01:00
|
|
|
feerate = 31337;
|
2019-09-09 18:11:24 +02:00
|
|
|
ci->fee_states = new_fee_states(w, c1.opener, &feerate);
|
2018-07-28 08:00:16 +02:00
|
|
|
mempat(scriptpubkey, tal_count(scriptpubkey));
|
2018-02-06 12:15:26 +01:00
|
|
|
c1.first_blocknum = 1;
|
2018-10-26 08:01:26 +02:00
|
|
|
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
|
|
|
|
NULL);
|
2018-03-07 01:06:07 +01:00
|
|
|
c1.final_key_idx = 1337;
|
2019-04-08 11:58:32 +02:00
|
|
|
p = new_peer(ld, 0, &id, &addr);
|
2018-02-12 11:12:55 +01:00
|
|
|
c1.peer = p;
|
2018-02-18 13:53:46 +01:00
|
|
|
c1.dbid = wallet_get_channel_dbid(w);
|
2018-02-12 11:12:55 +01:00
|
|
|
c1.state = CHANNELD_NORMAL;
|
2018-02-19 02:06:12 +01:00
|
|
|
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;
|
|
|
|
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 00:15:06 +01:00
|
|
|
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");
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2017-11-01 02:21:56 +01:00
|
|
|
db_begin_transaction(w->db);
|
|
|
|
CHECK(!wallet_err);
|
|
|
|
|
2018-02-18 13:53:46 +01:00
|
|
|
wallet_channel_insert(w, &c1);
|
|
|
|
|
2018-02-19 02:06:12 +01:00
|
|
|
/* 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 02:10:48 +01:00
|
|
|
CHECK_MSG(!wallet_err,
|
2017-11-01 02:21:56 +01:00
|
|
|
tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-01 02:21:56 +01:00
|
|
|
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 02:53:04 +01:00
|
|
|
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 11:12:55 +01:00
|
|
|
CHECK(c1.dbid == 1);
|
2017-08-14 22:06:59 +02:00
|
|
|
CHECK(c1.peer->dbid == 1);
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK(c1.their_shachain.id == 1);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
/* Variant 2: update with scid set */
|
2018-02-12 11:12:55 +01:00
|
|
|
c1.scid = talz(w, struct short_channel_id);
|
2018-02-19 02:06:12 +01:00
|
|
|
c1.last_was_revoke = !c1.last_was_revoke;
|
2018-02-06 12:15:26 +01:00
|
|
|
wallet_channel_save(w, &c1);
|
2017-11-01 02:10:48 +01:00
|
|
|
CHECK_MSG(!wallet_err,
|
2017-11-01 02:21:56 +01:00
|
|
|
tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-01 02:21:56 +01:00
|
|
|
CHECK_MSG(!wallet_err,
|
2019-05-02 20:28:33 +02: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 02:53:04 +01:00
|
|
|
tal_free(c2);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
|
|
|
/* Updates should not result in new ids */
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK(c1.dbid == 1);
|
2017-08-14 22:06:59 +02:00
|
|
|
CHECK(c1.peer->dbid == 1);
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK(c1.their_shachain.id == 1);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2018-02-19 02:06:12 +01:00
|
|
|
/* Variant 3: update with last_commit_sent */
|
2018-09-04 09:02:35 +02:00
|
|
|
c1.last_sent_commit = last_commit;
|
2018-02-06 12:15:26 +01:00
|
|
|
wallet_channel_save(w, &c1);
|
2017-11-01 02:21:56 +01:00
|
|
|
CHECK_MSG(!wallet_err, tal_fmt(w, "Insert into DB: %s", wallet_err));
|
2018-02-12 11:12:55 +01:00
|
|
|
CHECK_MSG(c2 = wallet_channel_load(w, c1.dbid), tal_fmt(w, "Load from DB"));
|
2017-11-01 02:21:56 +01:00
|
|
|
CHECK_MSG(!wallet_err,
|
2019-05-02 20:28:33 +02:00
|
|
|
tal_fmt(w, "Load from DB: %s", wallet_err));
|
2019-05-02 20:31:16 +02:00
|
|
|
CHECK_MSG(channelseq(&c1, c2), "Compare loaded with saved (v3)");
|
2018-02-14 02:53:04 +01:00
|
|
|
tal_free(c2);
|
2017-08-05 12:28:44 +02:00
|
|
|
|
2019-05-01 20:17:31 +02: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 09:35:45 +02: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 11:12:55 +01:00
|
|
|
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-02 20:28:33 +02:00
|
|
|
tal_fmt(w, "Load from DB: %s", wallet_err));
|
2019-05-02 20:31:16 +02:00
|
|
|
CHECK_MSG(channelseq(&c1, c2), "Compare loaded with saved (v4)");
|
2018-02-14 02:53:04 +01:00
|
|
|
tal_free(c2);
|
2017-11-26 00:06:33 +01:00
|
|
|
|
2019-05-01 20:17:31 +02: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));
|
|
|
|
CHECK_MSG(load = wallet_remote_ann_sigs_load(w, w, c1.dbid, &node_sig2, &bitcoin_sig2), tal_fmt(w, "Load ann sigs from DB"));
|
|
|
|
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)");
|
|
|
|
|
2017-11-01 02:21:56 +01:00
|
|
|
db_commit_transaction(w->db);
|
|
|
|
CHECK(!wallet_err);
|
2019-05-01 20:17:31 +02:00
|
|
|
|
2018-02-14 02:53:04 +01:00
|
|
|
/* Normally freed by destroy_channel, but we don't call that */
|
|
|
|
tal_free(p);
|
2017-08-05 12:28:44 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
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 11:12:55 +01:00
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2017-08-05 14:52:39 +02:00
|
|
|
CHECK(w);
|
|
|
|
|
2019-02-21 04:45:54 +01:00
|
|
|
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 13:54:46 +01:00
|
|
|
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 13:54:46 +01:00
|
|
|
CHECK(transaction_wrap(w->db, wallet_channel_config_save(w, cc1)));
|
2017-08-05 14:52:39 +02:00
|
|
|
|
2017-11-01 02:21:56 +01:00
|
|
|
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 11:12:55 +01:00
|
|
|
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;
|
2017-09-26 16:15:43 +02:00
|
|
|
struct htlc_in in, *hin;
|
|
|
|
struct htlc_out out, *hout;
|
2017-09-14 21:27:41 +02:00
|
|
|
struct preimage payment_key;
|
2018-02-12 11:12:55 +01:00
|
|
|
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 11:12:55 +01:00
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2019-12-12 00:39:10 +01:00
|
|
|
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 00:38:04 +01:00
|
|
|
struct onionreply *onionreply;
|
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 11:12:55 +01:00
|
|
|
chan->dbid = 1;
|
2017-09-26 16:15:43 +02:00
|
|
|
chan->peer = peer;
|
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));
|
2017-09-26 16:15:43 +02:00
|
|
|
in.key.id = 42;
|
2018-02-12 11:13:04 +01:00
|
|
|
in.key.channel = chan;
|
2019-02-21 04:45:55 +01:00
|
|
|
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 11:13:04 +01:00
|
|
|
out.key.channel = chan;
|
2019-02-21 04:45:55 +01:00
|
|
|
out.msat = AMOUNT_MSAT(41);
|
2017-09-14 21:27:41 +02:00
|
|
|
|
|
|
|
/* Store the htlc_in */
|
2017-11-01 02:10:48 +01:00
|
|
|
CHECK_MSG(transaction_wrap(w->db, wallet_htlc_save_in(w, chan, &in)),
|
2017-11-01 02:21:56 +01:00
|
|
|
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.");
|
|
|
|
/* Saving again should get us a collision */
|
2017-11-01 02:10:48 +01:00
|
|
|
CHECK_MSG(!transaction_wrap(w->db, wallet_htlc_save_in(w, chan, &in)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Saving two HTLCs with the same data must not succeed.");
|
2017-11-01 02:21:56 +01:00
|
|
|
CHECK(wallet_err);
|
|
|
|
wallet_err = tal_free(wallet_err);
|
2017-11-01 02:10:48 +01:00
|
|
|
|
2017-09-14 21:27:41 +02:00
|
|
|
/* Update */
|
2020-03-19 00:28:29 +01:00
|
|
|
CHECK_MSG(transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, RCVD_ADD_HTLC, NULL, 0, NULL, NULL, false)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Update HTLC with null payment_key failed");
|
|
|
|
CHECK_MSG(
|
2020-03-19 00:28:29 +01:00
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, SENT_REMOVE_HTLC, &payment_key, 0, NULL, NULL, false)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Update HTLC with payment_key failed");
|
2020-01-23 00:38:04 +01:00
|
|
|
onionreply = new_onionreply(tmpctx, tal_arrz(tmpctx, u8, 100));
|
2018-10-09 10:56:52 +02:00
|
|
|
CHECK_MSG(
|
2020-03-19 00:28:29 +01:00
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, SENT_REMOVE_HTLC, NULL, 0, onionreply, NULL, false)),
|
2020-02-18 01:00:58 +01:00
|
|
|
"Update HTLC with failonion failed");
|
|
|
|
CHECK_MSG(
|
2020-03-19 00:28:29 +01:00
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, in.dbid, SENT_REMOVE_HTLC, NULL, WIRE_INVALID_ONION_VERSION, NULL, NULL, false)),
|
2020-02-18 01:00:58 +01:00
|
|
|
"Update HTLC with failcode failed");
|
2017-09-14 21:27:41 +02:00
|
|
|
|
2017-11-01 02:10:48 +01:00
|
|
|
CHECK_MSG(transaction_wrap(w->db, wallet_htlc_save_out(w, chan, &out)),
|
2017-11-01 02:21:56 +01:00
|
|
|
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 02:10:48 +01:00
|
|
|
|
|
|
|
CHECK_MSG(!transaction_wrap(w->db, wallet_htlc_save_out(w, chan, &out)),
|
2017-09-14 21:27:41 +02:00
|
|
|
"Saving two HTLCs with the same data must not succeed.");
|
2017-11-01 02:21:56 +01:00
|
|
|
CHECK(wallet_err);
|
|
|
|
wallet_err = tal_free(wallet_err);
|
2020-02-18 01:00:58 +01:00
|
|
|
CHECK_MSG(
|
2020-03-19 00:28:29 +01:00
|
|
|
transaction_wrap(w->db, wallet_htlc_update(w, out.dbid, SENT_ADD_ACK_REVOCATION, NULL, 0, NULL, tal_arrz(tmpctx, u8, 100), false)),
|
2020-02-18 01:00:58 +01:00
|
|
|
"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 02:21:56 +01:00
|
|
|
db_begin_transaction(w->db);
|
|
|
|
CHECK(!wallet_err);
|
|
|
|
|
2019-12-12 00:39:10 +01:00
|
|
|
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 02:21:56 +01:00
|
|
|
db_commit_transaction(w->db);
|
2018-09-03 03:08:53 +02:00
|
|
|
|
2019-12-12 00:39:10 +01:00
|
|
|
htlcs_resubmit(w->ld, rem);
|
2017-11-01 02:21:56 +01:00
|
|
|
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);
|
|
|
|
htlc_in_map_clear(htlcs_in);
|
|
|
|
htlc_out_map_clear(htlcs_out);
|
|
|
|
|
2017-09-14 21:27:41 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:12:55 +01:00
|
|
|
static bool test_payment_crud(struct lightningd *ld, const tal_t *ctx)
|
2017-11-10 15:54:56 +01:00
|
|
|
{
|
2018-01-17 21:29:49 +01:00
|
|
|
struct wallet_payment *t = tal(ctx, struct wallet_payment), *t2;
|
2018-02-12 11:12:55 +01:00
|
|
|
struct wallet *w = create_test_wallet(ld, ctx);
|
2017-11-10 15:54:56 +01:00
|
|
|
|
2018-01-17 21:29:49 +01:00
|
|
|
mempat(t, sizeof(*t));
|
2019-11-07 23:13:29 +01:00
|
|
|
t->destination = tal(t, struct node_id);
|
|
|
|
memset(t->destination, 2, sizeof(struct node_id));
|
2017-11-10 15:54:56 +01:00
|
|
|
|
2018-01-17 21:29:49 +01:00
|
|
|
t->id = 0;
|
2019-02-21 04:45:55 +01:00
|
|
|
t->msatoshi = AMOUNT_MSAT(100);
|
|
|
|
t->msatoshi_sent = AMOUNT_MSAT(101);
|
2019-12-12 00:16:23 +01:00
|
|
|
t->total_msat = t->msatoshi;
|
2018-01-17 21:29:49 +01:00
|
|
|
t->status = PAYMENT_PENDING;
|
|
|
|
t->payment_preimage = NULL;
|
|
|
|
memset(&t->payment_hash, 1, sizeof(t->payment_hash));
|
2019-12-12 00:16:23 +01:00
|
|
|
t->partid = 0;
|
2017-11-10 15:54:56 +01:00
|
|
|
|
|
|
|
db_begin_transaction(w->db);
|
2020-01-07 21:00:51 +01:00
|
|
|
t2 = tal_dup(NULL, struct wallet_payment, t);
|
|
|
|
wallet_payment_setup(w, t2);
|
|
|
|
wallet_payment_store(w, take(t2));
|
2019-12-12 00:16:23 +01:00
|
|
|
t2 = wallet_payment_by_hash(ctx, w, &t->payment_hash, 0);
|
2017-11-10 15:54:56 +01:00
|
|
|
CHECK(t2 != NULL);
|
2018-01-17 21:29:49 +01:00
|
|
|
CHECK(t2->status == t->status);
|
2019-12-12 00:16:23 +01:00
|
|
|
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 04:45:55 +01:00
|
|
|
CHECK(amount_msat_eq(t2->msatoshi, t->msatoshi));
|
|
|
|
CHECK(amount_msat_eq(t2->msatoshi_sent, t->msatoshi_sent));
|
2019-12-12 00:16:23 +01:00
|
|
|
CHECK(amount_msat_eq(t2->total_msat, t->total_msat));
|
2018-01-17 21:29:49 +01:00
|
|
|
CHECK(!t2->payment_preimage);
|
2017-11-10 15:54:56 +01:00
|
|
|
|
2018-01-17 21:29:49 +01:00
|
|
|
t->status = PAYMENT_COMPLETE;
|
|
|
|
t->payment_preimage = tal(w, struct preimage);
|
|
|
|
memset(t->payment_preimage, 2, sizeof(*t->payment_preimage));
|
2019-12-12 00:16:23 +01:00
|
|
|
wallet_payment_set_status(w, &t->payment_hash, t->partid, t->status,
|
2018-01-17 21:29:49 +01:00
|
|
|
t->payment_preimage);
|
2019-12-12 00:16:23 +01:00
|
|
|
t2 = wallet_payment_by_hash(ctx, w, &t->payment_hash, t->partid);
|
2018-01-17 21:22:22 +01:00
|
|
|
CHECK(t2 != NULL);
|
2018-01-17 21:29:49 +01:00
|
|
|
CHECK(t2->status == t->status);
|
2019-12-12 00:16:23 +01:00
|
|
|
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 04:45:55 +01:00
|
|
|
CHECK(amount_msat_eq(t2->msatoshi, t->msatoshi));
|
|
|
|
CHECK(amount_msat_eq(t2->msatoshi_sent, t->msatoshi_sent));
|
2018-07-04 07:30:02 +02:00
|
|
|
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-16 00:13:22 +02:00
|
|
|
int main(int argc, const char *argv[])
|
2017-05-31 15:26:30 +02:00
|
|
|
{
|
2020-05-16 00:13:22 +02: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 07:10:20 +01:00
|
|
|
struct lightningd *ld;
|
|
|
|
|
|
|
|
ld = tal(tmpctx, struct lightningd);
|
2019-03-13 17:20:54 +01:00
|
|
|
ld->config = test_config;
|
2018-02-12 11:12:55 +01:00
|
|
|
|
|
|
|
/* Only elements in ld we should access */
|
|
|
|
list_head_init(&ld->peers);
|
2019-04-08 11:58:32 +02:00
|
|
|
node_id_from_hexstr("02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66, &ld->id);
|
2018-02-12 11:12:55 +01:00
|
|
|
/* Accessed in peer destructor sanity check */
|
|
|
|
htlc_in_map_init(&ld->htlcs_in);
|
|
|
|
htlc_out_map_init(&ld->htlcs_out);
|
2017-05-31 15:26:30 +02:00
|
|
|
|
2018-06-04 16:19:14 +02:00
|
|
|
ok &= test_wallet_outputs(ld, tmpctx);
|
|
|
|
ok &= test_shachain_crud(ld, tmpctx);
|
2018-02-12 11:12:55 +01:00
|
|
|
ok &= test_channel_crud(ld, tmpctx);
|
|
|
|
ok &= test_channel_config_crud(ld, tmpctx);
|
|
|
|
ok &= test_htlc_crud(ld, tmpctx);
|
|
|
|
ok &= test_payment_crud(ld, tmpctx);
|
2018-07-27 12:55:37 +02:00
|
|
|
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) {
|
|
|
|
take_cleanup();
|
2020-05-16 00:13:22 +02:00
|
|
|
common_shutdown();
|
2018-06-04 16:19:14 +02:00
|
|
|
}
|
2017-05-31 15:26:30 +02:00
|
|
|
return !ok;
|
|
|
|
}
|