mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
utxo: wire support for unspent transactions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
19f3b68d28
commit
fddb38126d
3 changed files with 63 additions and 1 deletions
|
@ -39,7 +39,8 @@ LIGHTNINGD_LIB_SRC := \
|
|||
lightningd/cryptomsg.c \
|
||||
lightningd/funding_tx.c \
|
||||
lightningd/htlc_tx.c \
|
||||
lightningd/key_derive.c
|
||||
lightningd/key_derive.c \
|
||||
lightningd/utxo.c
|
||||
|
||||
LIGHTNINGD_LIB_OBJS := $(LIGHTNINGD_LIB_SRC:.c=.o)
|
||||
LIGHTNINGD_LIB_HEADERS := $(LIGHTNINGD_LIB_SRC:.c=.h)
|
||||
|
|
37
lightningd/utxo.c
Normal file
37
lightningd/utxo.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include <lightningd/utxo.h>
|
||||
#include <wire/wire.h>
|
||||
|
||||
void towire_utxo(u8 **pptr, const struct utxo *utxo)
|
||||
{
|
||||
towire_sha256_double(pptr, &utxo->txid);
|
||||
towire_u32(pptr, utxo->outnum);
|
||||
towire_u64(pptr, utxo->amount);
|
||||
towire_u32(pptr, utxo->keyindex);
|
||||
towire_bool(pptr, utxo->is_p2sh);
|
||||
}
|
||||
|
||||
void fromwire_utxo(const u8 **ptr, size_t *max, struct utxo *utxo)
|
||||
{
|
||||
fromwire_sha256_double(ptr, max, &utxo->txid);
|
||||
utxo->outnum = fromwire_u32(ptr, max);
|
||||
utxo->amount = fromwire_u64(ptr, max);
|
||||
utxo->keyindex = fromwire_u32(ptr, max);
|
||||
utxo->is_p2sh = fromwire_bool(ptr, max);
|
||||
}
|
||||
|
||||
void fromwire_utxo_array(const u8 **ptr, size_t *max,
|
||||
struct utxo *utxo, size_t num)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
fromwire_utxo(ptr, max, &utxo[i]);
|
||||
}
|
||||
|
||||
void towire_utxo_array(u8 **pptr, const struct utxo *utxo, size_t num)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
towire_utxo(pptr, &utxo[i]);
|
||||
}
|
24
lightningd/utxo.h
Normal file
24
lightningd/utxo.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef LIGHTNING_LIGHTNINGD_UTXO_H
|
||||
#define LIGHTNING_LIGHTNINGD_UTXO_H
|
||||
#include "config.h"
|
||||
#include <bitcoin/shadouble.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <ccan/tal/tal.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct utxo {
|
||||
struct sha256_double txid;
|
||||
u32 outnum;
|
||||
u64 amount;
|
||||
u32 keyindex;
|
||||
bool is_p2sh;
|
||||
};
|
||||
|
||||
void towire_utxo(u8 **pptr, const struct utxo *utxo);
|
||||
void fromwire_utxo(const u8 **ptr, size_t *max, struct utxo *utxo);
|
||||
|
||||
void fromwire_utxo_array(const u8 **ptr, size_t *max,
|
||||
struct utxo *utxo, size_t num);
|
||||
|
||||
void towire_utxo_array(u8 **pptr, const struct utxo *utxo, size_t num);
|
||||
#endif /* LIGHTNING_LIGHTNINGD_UTXO_H */
|
Loading…
Add table
Reference in a new issue