wally: Post-migration cleanups

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-03-25 17:08:29 +01:00
committed by Rusty Russell
parent 509bb2c7ae
commit 21a0dad016
2 changed files with 3 additions and 19 deletions

View File

@@ -16,7 +16,7 @@
int bitcoin_tx_add_output(struct bitcoin_tx *tx, u8 *script,
struct amount_sat *amount)
{
size_t i = tx->used_outputs;
size_t i = tx->wtx->num_outputs;
struct wally_tx_output *output;
assert(i < tx->wtx->outputs_allocation_len);
@@ -26,7 +26,6 @@ int bitcoin_tx_add_output(struct bitcoin_tx *tx, u8 *script,
wally_tx_add_output(tx->wtx, output);
wally_tx_output_free(output);
tx->used_outputs++;
return i;
}
@@ -34,7 +33,7 @@ int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
u32 outnum, u32 sequence,
const struct amount_sat *amount, u8 *script)
{
size_t i = tx->used_inputs;
size_t i = tx->wtx->num_inputs;
struct wally_tx_input *input;
assert(i < tx->wtx->inputs_allocation_len);
@@ -50,7 +49,6 @@ int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
tx->input_amounts[i] = tal_free(tx->input_amounts[i]);
tx->input_amounts[i] = tal_dup(tx, struct amount_sat, amount);
tx->used_inputs++;
return i;
}
@@ -71,17 +69,13 @@ bool bitcoin_tx_check(const struct bitcoin_tx *tx)
if (written != tal_bytelen(newtx))
return false;
if (tx->used_inputs != tx->wtx->num_inputs ||
tx->used_outputs != tx->wtx->num_outputs)
return false;
return true;
}
void bitcoin_tx_output_set_amount(struct bitcoin_tx *tx, int outnum,
struct amount_sat *amount)
{
assert(outnum < tx->used_outputs);
assert(outnum < tx->wtx->num_outputs);
tx->wtx->outputs[outnum].satoshi = amount->satoshis; /* Raw: low-level helper */
}
@@ -283,9 +277,6 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count,
varint_t output_count)
{
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
tx->used_inputs = 0;
tx->used_outputs = 0;
wally_tx_init_alloc(WALLY_TX_VERSION_2, 0, input_count, output_count,
&tx->wtx);
tal_add_destructor(tx, bitcoin_tx_destroy);
@@ -312,9 +303,6 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
tx->input_amounts =
tal_arrz(tx, struct amount_sat *, tx->wtx->inputs_allocation_len);
tx->used_outputs = tx->wtx->num_outputs;
tx->used_inputs = tx->wtx->num_inputs;
*cursor += wsize;
*max -= wsize;
return tx;

View File

@@ -23,10 +23,6 @@ struct bitcoin_tx {
* unknown) */
struct amount_sat **input_amounts;
struct wally_tx *wtx;
/* Keep track of how many inputs and outputs were filled so far. This
* is needed since we allocate them in bulk. */
size_t used_inputs, used_outputs;
};
struct bitcoin_tx_output {