2017-08-28 18:06:01 +02:00
|
|
|
#ifndef LIGHTNING_COMMON_UTXO_H
|
|
|
|
#define LIGHTNING_COMMON_UTXO_H
|
2017-02-21 05:45:29 +01:00
|
|
|
#include "config.h"
|
2019-07-30 16:14:43 +02:00
|
|
|
#include <bitcoin/chainparams.h>
|
2017-12-20 12:44:00 +01:00
|
|
|
#include <bitcoin/pubkey.h>
|
|
|
|
#include <bitcoin/shadouble.h>
|
2017-12-18 07:41:52 +01:00
|
|
|
#include <bitcoin/tx.h>
|
2017-02-21 05:45:29 +01:00
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
2019-02-21 03:39:51 +01:00
|
|
|
#include <common/amount.h>
|
2019-04-08 11:58:32 +02:00
|
|
|
#include <common/node_id.h>
|
2017-02-21 05:45:29 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2018-12-03 00:02:11 +01:00
|
|
|
struct ext_key;
|
|
|
|
|
2017-12-20 12:44:00 +01:00
|
|
|
/* Information needed for their_unilateral/to-us outputs */
|
|
|
|
struct unilateral_close_info {
|
|
|
|
u64 channel_id;
|
2019-04-08 11:58:32 +02:00
|
|
|
struct node_id peer_id;
|
2019-09-10 04:24:27 +02:00
|
|
|
/* NULL if this is an option_static_remotekey commitment */
|
|
|
|
struct pubkey *commitment_point;
|
2017-12-20 12:44:00 +01:00
|
|
|
};
|
|
|
|
|
2017-02-21 05:45:29 +01:00
|
|
|
struct utxo {
|
2017-12-18 07:41:52 +01:00
|
|
|
struct bitcoin_txid txid;
|
2017-02-21 05:45:29 +01:00
|
|
|
u32 outnum;
|
2019-02-21 03:39:51 +01:00
|
|
|
struct amount_sat amount;
|
2017-02-21 05:45:29 +01:00
|
|
|
u32 keyindex;
|
|
|
|
bool is_p2sh;
|
2017-06-05 13:59:51 +02:00
|
|
|
u8 status;
|
2017-12-20 12:44:00 +01:00
|
|
|
|
|
|
|
/* Optional unilateral close information, NULL if this is just
|
|
|
|
* a HD key */
|
|
|
|
struct unilateral_close_info *close_info;
|
2018-02-26 11:36:48 +01:00
|
|
|
|
|
|
|
/* NULL if we haven't seen it in a block, otherwise the block it's in */
|
2018-03-22 00:13:16 +01:00
|
|
|
const u32 *blockheight;
|
2018-02-26 11:36:48 +01:00
|
|
|
|
|
|
|
/* NULL if not spent yet, otherwise, the block the spending transaction is in */
|
2018-03-22 00:13:16 +01:00
|
|
|
const u32 *spendheight;
|
2019-02-22 15:47:30 +01:00
|
|
|
|
|
|
|
/* The scriptPubkey if it is known */
|
|
|
|
u8 *scriptPubkey;
|
2019-10-01 00:05:28 +02:00
|
|
|
|
|
|
|
/* scriptSig. Only for P2SH outputs */
|
|
|
|
u8 *scriptSig;
|
2017-02-21 05:45:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void towire_utxo(u8 **pptr, const struct utxo *utxo);
|
2018-02-08 02:23:46 +01:00
|
|
|
struct utxo *fromwire_utxo(const tal_t *ctx, const u8 **ptr, size_t *max);
|
2018-12-03 00:02:11 +01:00
|
|
|
|
|
|
|
/* Create a tx, and populate inputs from utxos */
|
|
|
|
struct bitcoin_tx *tx_spending_utxos(const tal_t *ctx,
|
2019-07-30 16:14:43 +02:00
|
|
|
const struct chainparams *chainparams,
|
2018-12-03 00:02:11 +01:00
|
|
|
const struct utxo **utxos,
|
|
|
|
const struct ext_key *bip32_base,
|
2019-08-12 21:29:13 +02:00
|
|
|
bool add_change_output,
|
2020-01-29 12:59:06 +01:00
|
|
|
size_t num_output,
|
|
|
|
u32 nlocktime,
|
|
|
|
u32 nsequence);
|
2018-12-03 00:02:11 +01:00
|
|
|
|
2017-08-28 18:06:01 +02:00
|
|
|
#endif /* LIGHTNING_COMMON_UTXO_H */
|