Browse Source

bitcoin/tx: implement wally_tx_clone (badly) for now.

When libwally exposes it, we can use theirs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
nifty/pset-pre
Rusty Russell 5 years ago
committed by Christian Decker
parent
commit
d737b54625
  1. 15
      bitcoin/tx.c
  2. 2
      bitcoin/tx.h

15
bitcoin/tx.c

@ -17,6 +17,21 @@
#define SEGREGATED_WITNESS_FLAG 0x1
/* FIXME: When wally exposes this, we will clash and can remove this one */
int wally_tx_clone(struct wally_tx *tx, struct wally_tx **output)
{
u8 *txlin = linearize_wtx(NULL, tx);
int flags = WALLY_TX_FLAG_USE_WITNESS;
int ret;
if (chainparams->is_elements)
flags |= WALLY_TX_FLAG_USE_ELEMENTS;
ret = wally_tx_from_bytes(txlin, tal_bytelen(txlin), flags, output);
tal_free(txlin);
return ret;
}
int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
u8 *wscript, struct amount_sat amount)
{

2
bitcoin/tx.h

@ -217,4 +217,6 @@ void towire_bitcoin_tx_output(u8 **pptr, const struct bitcoin_tx_output *output)
* Get the base64 string encoded PSBT of a bitcoin transaction.
*/
char *bitcoin_tx_to_psbt_base64(const tal_t *ctx, struct bitcoin_tx *tx);
int wally_tx_clone(struct wally_tx *tx, struct wally_tx **output);
#endif /* LIGHTNING_BITCOIN_TX_H */

Loading…
Cancel
Save