2017-08-28 18:06:01 +02:00
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_CHANNEL_COMMIT_TX_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_CHANNEL_COMMIT_TX_H
|
2017-02-07 02:44:22 +01:00
|
|
|
#include "config.h"
|
2017-08-18 06:43:53 +02:00
|
|
|
#include <bitcoin/pubkey.h>
|
2017-08-29 06:12:04 +02:00
|
|
|
#include <channeld/channeld_htlc.h>
|
2017-08-28 18:04:01 +02:00
|
|
|
#include <common/htlc.h>
|
2017-08-28 18:02:01 +02:00
|
|
|
#include <common/initial_commit_tx.h>
|
2017-02-07 02:44:22 +01:00
|
|
|
|
2017-08-18 06:43:53 +02:00
|
|
|
struct keyset;
|
2017-02-07 02:44:22 +01:00
|
|
|
struct sha256_double;
|
|
|
|
|
2017-02-21 05:45:28 +01:00
|
|
|
/**
|
|
|
|
* commit_tx_num_untrimmed: how many of these htlc outputs will commit tx have?
|
|
|
|
* @htlcs: tal_arr of HTLCs
|
|
|
|
* @feerate_per_kw: feerate to use
|
|
|
|
* @dust_limit_satoshis: dust limit below which to trim outputs.
|
|
|
|
* @side: from which side's point of view
|
|
|
|
*
|
|
|
|
* We need @side because HTLC fees are different for offered and
|
|
|
|
* received HTLCs.
|
|
|
|
*/
|
|
|
|
size_t commit_tx_num_untrimmed(const struct htlc **htlcs,
|
|
|
|
u64 feerate_per_kw, u64 dust_limit_satoshis,
|
|
|
|
enum side side);
|
|
|
|
|
2017-02-21 05:45:28 +01:00
|
|
|
/**
|
|
|
|
* commit_tx: create (unsigned) commitment tx to spend the funding tx output
|
|
|
|
* @ctx: context to allocate transaction and @htlc_map from.
|
|
|
|
* @funding_txid, @funding_out, @funding_satoshis: funding outpoint.
|
|
|
|
* @funder: is the LOCAL or REMOTE paying the fee?
|
2017-08-18 06:43:53 +02:00
|
|
|
* @keyset: keys derived for this commit tx.
|
2017-02-21 05:45:28 +01:00
|
|
|
* @feerate_per_kw: feerate to use
|
|
|
|
* @dust_limit_satoshis: dust limit below which to trim outputs.
|
|
|
|
* @self_pay_msat: amount to pay directly to self
|
|
|
|
* @other_pay_msat: amount to pay directly to the other side
|
|
|
|
* @htlcs: tal_arr of htlcs committed by transaction (some may be trimmed)
|
2017-02-24 06:52:56 +01:00
|
|
|
* @htlc_map: outputed map of outnum->HTLC (NULL for direct outputs), or NULL.
|
2017-02-21 05:45:28 +01:00
|
|
|
* @obscured_commitment_number: number to encode in commitment transaction
|
|
|
|
* @side: side to generate commitment transaction for.
|
|
|
|
*
|
|
|
|
* We need to be able to generate the remote side's tx to create signatures,
|
|
|
|
* but the BOLT is expressed in terms of generating our local commitment
|
|
|
|
* transaction, so we carefully use the terms "self" and "other" here.
|
|
|
|
*/
|
2017-02-07 02:44:22 +01:00
|
|
|
struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
|
|
|
const struct sha256_double *funding_txid,
|
|
|
|
unsigned int funding_txout,
|
|
|
|
u64 funding_satoshis,
|
|
|
|
enum side funder,
|
|
|
|
u16 to_self_delay,
|
2017-08-18 06:43:53 +02:00
|
|
|
const struct keyset *keyset,
|
2017-02-07 02:44:22 +01:00
|
|
|
u64 feerate_per_kw,
|
|
|
|
u64 dust_limit_satoshis,
|
2017-02-21 05:45:28 +01:00
|
|
|
u64 self_pay_msat,
|
|
|
|
u64 other_pay_msat,
|
2017-02-07 02:44:22 +01:00
|
|
|
const struct htlc **htlcs,
|
2017-02-07 02:44:22 +01:00
|
|
|
const struct htlc ***htlcmap,
|
2017-02-21 05:45:28 +01:00
|
|
|
u64 obscured_commitment_number,
|
|
|
|
enum side side);
|
2017-08-18 06:43:53 +02:00
|
|
|
|
2017-08-28 18:06:01 +02:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_COMMIT_TX_H */
|