mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
psbt: add psbt to bitcoin tx struct
This commit is contained in:
parent
24ecb3e2b9
commit
7a0624797e
3 changed files with 20 additions and 1 deletions
15
bitcoin/tx.c
15
bitcoin/tx.c
|
@ -429,6 +429,7 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx,
|
||||||
varint_t input_count, varint_t output_count,
|
varint_t input_count, varint_t output_count,
|
||||||
u32 nlocktime)
|
u32 nlocktime)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
||||||
assert(chainparams);
|
assert(chainparams);
|
||||||
|
|
||||||
|
@ -447,6 +448,12 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx,
|
||||||
tx->wtx->version = 2;
|
tx->wtx->version = 2;
|
||||||
tx->output_witscripts = tal_arrz(tx, struct witscript*, output_count);
|
tx->output_witscripts = tal_arrz(tx, struct witscript*, output_count);
|
||||||
tx->chainparams = chainparams;
|
tx->chainparams = chainparams;
|
||||||
|
|
||||||
|
ret = wally_psbt_init_alloc(input_count, output_count,
|
||||||
|
0, &tx->psbt);
|
||||||
|
assert(ret == WALLY_OK);
|
||||||
|
ret = wally_psbt_set_global_tx(tx->psbt, tx->wtx);
|
||||||
|
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +474,7 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
|
||||||
size_t *max)
|
size_t *max)
|
||||||
{
|
{
|
||||||
size_t wsize;
|
size_t wsize;
|
||||||
int flags = WALLY_TX_FLAG_USE_WITNESS;
|
int flags = WALLY_TX_FLAG_USE_WITNESS, ret;
|
||||||
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
||||||
|
|
||||||
if (chainparams->is_elements)
|
if (chainparams->is_elements)
|
||||||
|
@ -494,6 +501,12 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
|
||||||
tal_arrz(tx, struct amount_sat *, tx->wtx->inputs_allocation_len);
|
tal_arrz(tx, struct amount_sat *, tx->wtx->inputs_allocation_len);
|
||||||
tx->chainparams = chainparams;
|
tx->chainparams = chainparams;
|
||||||
|
|
||||||
|
ret = wally_psbt_init_alloc(tx->wtx->num_inputs, tx->wtx->num_outputs,
|
||||||
|
0, &tx->psbt);
|
||||||
|
assert(ret == WALLY_OK);
|
||||||
|
ret = wally_psbt_set_global_tx(tx->psbt, tx->wtx);
|
||||||
|
|
||||||
|
|
||||||
*cursor += wsize;
|
*cursor += wsize;
|
||||||
*max -= wsize;
|
*max -= wsize;
|
||||||
return tx;
|
return tx;
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
|
#include <wally_psbt.h>
|
||||||
#include <wally_transaction.h>
|
#include <wally_transaction.h>
|
||||||
|
|
||||||
#define BITCOIN_TX_DEFAULT_SEQUENCE 0xFFFFFFFF
|
#define BITCOIN_TX_DEFAULT_SEQUENCE 0xFFFFFFFF
|
||||||
|
struct wally_psbt;
|
||||||
|
|
||||||
struct witscript {
|
struct witscript {
|
||||||
u8 *ptr;
|
u8 *ptr;
|
||||||
|
@ -33,6 +35,9 @@ struct bitcoin_tx {
|
||||||
|
|
||||||
/* Keep a reference to the ruleset we have to abide by */
|
/* Keep a reference to the ruleset we have to abide by */
|
||||||
const struct chainparams *chainparams;
|
const struct chainparams *chainparams;
|
||||||
|
|
||||||
|
/* psbt struct */
|
||||||
|
struct wally_psbt *psbt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bitcoin_tx_output {
|
struct bitcoin_tx_output {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "permute_tx.h"
|
#include "permute_tx.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <wally_psbt.h>
|
||||||
|
|
||||||
static bool input_better(const struct wally_tx_input *a,
|
static bool input_better(const struct wally_tx_input *a,
|
||||||
const struct wally_tx_input *b)
|
const struct wally_tx_input *b)
|
||||||
|
|
Loading…
Add table
Reference in a new issue