core-lightning/common/wallet_tx.h
darosior ac038b340b fundchannel: Add a new 'utxo' parameter
This new parameter takes a list of outpoints (as txid:vout) and fund a channel from the corresponding utxos.
Example : fundchannel <id> 10000 normal 1 [10767f0db0e568127fffd7f70a154d4599f42d62babf63230a7c3378bfce3cb0:0, c9e040e0b5fc8c59d5e7834108fbc5583001f414dd83faf0a05cff9d1a92d32c:0]
2019-06-11 23:24:07 +00:00

62 lines
1.7 KiB
C

#ifndef LIGHTNING_COMMON_WALLET_TX_H
#define LIGHTNING_COMMON_WALLET_TX_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <common/amount.h>
#include <lightningd/json.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
/* A specification of funds in the wallet used for funding channels and
* withdrawal.
*/
struct wallet_tx {
struct command *cmd;
struct amount_sat amount, change;
u32 change_key_index;
const struct utxo **utxos;
bool all_funds; /* In this case, amount is a maximum. */
};
void wtx_init(struct command *cmd, struct wallet_tx *wtx, struct amount_sat max);
struct command_result *param_wtx(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t *tok,
struct wallet_tx *wtx);
struct command_result *param_utxos(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t *tok,
const struct utxo ***utxos);
struct command_result *wtx_select_utxos(struct wallet_tx *tx,
u32 fee_rate_per_kw,
size_t out_len,
u32 maxheight);
struct command_result *wtx_from_utxos(struct wallet_tx *tx,
u32 fee_rate_per_kw,
size_t out_len,
u32 maxheight,
const struct utxo **utxos);
static inline u32 minconf_to_maxheight(u32 minconf, struct lightningd *ld)
{
/* No confirmations is special, we need to disable the check in the
* selection */
if (minconf == 0)
return 0;
/* Avoid wrapping around and suddenly allowing any confirmed
* outputs. Since we can't have a coinbase output, and 0 is taken for
* the disable case, we can just clamp to 1. */
if (minconf >= ld->topology->tip->height)
return 1;
return ld->topology->tip->height - minconf + 1;
}
#endif /* LIGHTNING_COMMON_WALLET_TX_H */