Browse Source

bitcoin: pull up elements_fee calc to allow wtx passed in

We're moving away from bitcoin_tx, slowly
bump-pyln-proto
niftynei 5 years ago
committed by Rusty Russell
parent
commit
65f01d8180
  1. 11
      bitcoin/tx.c
  2. 5
      bitcoin/tx.h

11
bitcoin/tx.c

@ -98,11 +98,16 @@ int bitcoin_tx_add_multi_outputs(struct bitcoin_tx *tx,
return tx->wtx->num_outputs; return tx->wtx->num_outputs;
} }
bool elements_tx_output_is_fee(const struct bitcoin_tx *tx, int outnum) bool elements_wtx_output_is_fee(const struct wally_tx *tx, int outnum)
{ {
assert(outnum < tx->wtx->num_outputs); assert(outnum < tx->num_outputs);
return chainparams->is_elements && return chainparams->is_elements &&
tx->wtx->outputs[outnum].script_len == 0; tx->outputs[outnum].script_len == 0;
}
bool elements_tx_output_is_fee(const struct bitcoin_tx *tx, int outnum)
{
return elements_wtx_output_is_fee(tx->wtx, outnum);
} }
struct amount_sat bitcoin_tx_compute_fee_w_inputs(const struct bitcoin_tx *tx, struct amount_sat bitcoin_tx_compute_fee_w_inputs(const struct bitcoin_tx *tx,

5
bitcoin/tx.h

@ -210,6 +210,11 @@ bool bitcoin_tx_check(const struct bitcoin_tx *tx);
*/ */
void bitcoin_tx_finalize(struct bitcoin_tx *tx); void bitcoin_tx_finalize(struct bitcoin_tx *tx);
/**
* Returns true if the given outnum is a fee output
*/
bool elements_wtx_output_is_fee(const struct wally_tx *tx, int outnum);
/** /**
* Returns true if the given outnum is a fee output * Returns true if the given outnum is a fee output
*/ */

Loading…
Cancel
Save