bitcoin: add fromwire/towire routines for bitcoin_outpoint.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-03-16 06:55:21 +10:30
parent cce280400c
commit 67fc6e6267
2 changed files with 16 additions and 0 deletions

View File

@ -716,6 +716,19 @@ void towire_bitcoin_txid(u8 **pptr, const struct bitcoin_txid *txid)
towire_sha256_double(pptr, &txid->shad);
}
void towire_bitcoin_outpoint(u8 **pptr, const struct bitcoin_outpoint *outp)
{
towire_bitcoin_txid(pptr, &outp->txid);
towire_u32(pptr, outp->n);
}
void fromwire_bitcoin_outpoint(const u8 **cursor, size_t *max,
struct bitcoin_outpoint *outp)
{
fromwire_bitcoin_txid(cursor, max, &outp->txid);
outp->n = fromwire_u32(cursor, max);
}
void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx)
{
u8 *lin = linearize_tx(tmpctx, tx);

View File

@ -254,6 +254,9 @@ void towire_bitcoin_txid(u8 **pptr, const struct bitcoin_txid *txid);
void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx);
void towire_bitcoin_tx_output(u8 **pptr, const struct bitcoin_tx_output *output);
void towire_wally_tx(u8 **pptr, const struct wally_tx *wtx);
void towire_bitcoin_outpoint(u8 **pptr, const struct bitcoin_outpoint *outp);
void fromwire_bitcoin_outpoint(const u8 **cursor, size_t *max,
struct bitcoin_outpoint *outp);
/* Various weights of transaction parts. */
size_t bitcoin_tx_core_weight(size_t num_inputs, size_t num_outputs);