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>
This commit is contained in:
Rusty Russell 2020-05-27 11:11:31 +09:30 committed by Christian Decker
parent f9300e8480
commit d737b54625
2 changed files with 17 additions and 0 deletions

View file

@ -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)
{

View file

@ -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 */