core-lightning/bitcoin/tx_parts.h
Rusty Russell dafaf854c5 bitcoin/tx_parts: infrastructure for partial bitcoin txs.
`struct tx_parts` is just a txid and a bunch of inputs and outputs,
some of which may be NULL.

This is both a nod towards a future where we (or our peer) can combine
HTLCs or (in an eltoo world) commitments, although for the moment all
our tx_parts will be complete.

It also matches our plan to split `bitcoin_tx` into two types: this
`struct tx_parts` where we don't know input amounts etc, and `psbt`
where we do.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30

30 lines
1.0 KiB
C

/* This represents a specific part of a transaction, without including
* all the metadata (which we might not know, if we didn't make the
* transction ourselves). */
#ifndef LIGHTNING_BITCOIN_TX_PARTS_H
#define LIGHTNING_BITCOIN_TX_PARTS_H
#include "config.h"
#include <bitcoin/tx.h>
#include <wally_transaction.h>
struct tx_parts {
/* The txid of this transacation */
struct bitcoin_txid txid;
/* A subset of inputs: NULL means it's not included. */
struct wally_tx_input **inputs;
/* A subset of outputs: NULL means it's not included. */
struct wally_tx_output **outputs;
};
/* Initialize this from a wally_tx: input/output == -1 for all,
* otherwise the input/output number to include. */
struct tx_parts *tx_parts_from_wally_tx(const tal_t *ctx,
const struct wally_tx *wtx,
int input, int output);
/* Wire marshalling and unmarshalling */
struct tx_parts *fromwire_tx_parts(const tal_t *ctx,
const u8 **cursor, size_t *max);
void towire_tx_parts(u8 **pptr, const struct tx_parts *tx_parts);
#endif /* LIGHTNING_BITCOIN_TX_PARTS_H */