Browse Source

tx: Make elements_add_fee_output private

travis-debug
Christian Decker 5 years ago
committed by Rusty Russell
parent
commit
c236bf0fbd
  1. 12
      bitcoin/tx.c
  2. 12
      bitcoin/tx.h
  3. 8
      onchaind/onchaind.c

12
bitcoin/tx.c

@ -98,7 +98,17 @@ static struct amount_sat bitcoin_tx_compute_fee(const struct bitcoin_tx *tx)
return fee; return fee;
} }
int elements_tx_add_fee_output(struct bitcoin_tx *tx) /**
* Add an explicit fee output if necessary.
*
* An explicit fee output is only necessary if we are using an elements
* transaction, and we have a non-zero fee. This method may be called multiple
* times.
*
* Returns the position of the fee output, or -1 in the case of non-elements
* transactions.
*/
static int elements_tx_add_fee_output(struct bitcoin_tx *tx)
{ {
struct amount_sat fee = bitcoin_tx_compute_fee(tx); struct amount_sat fee = bitcoin_tx_compute_fee(tx);
int pos; int pos;

12
bitcoin/tx.h

@ -165,16 +165,4 @@ 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);
/**
* Add an explicit fee output if necessary.
*
* An explicit fee output is only necessary if we are using an elements
* transaction, and we have a non-zero fee. This method may be called multiple
* times.
*
* Returns the position of the fee output, or -1 in the case of non-elements
* transactions.
*/
int elements_tx_add_fee_output(struct bitcoin_tx *tx);
#endif /* LIGHTNING_BITCOIN_TX_H */ #endif /* LIGHTNING_BITCOIN_TX_H */

8
onchaind/onchaind.c

@ -148,7 +148,7 @@ static bool grind_htlc_tx_fee(struct amount_sat *fee,
break; break;
bitcoin_tx_output_set_amount(tx, 0, out); bitcoin_tx_output_set_amount(tx, 0, out);
elements_tx_add_fee_output(tx); bitcoin_tx_finalize(tx);
if (!check_tx_sig(tx, 0, NULL, wscript, if (!check_tx_sig(tx, 0, NULL, wscript,
&keyset->other_htlc_key, remotesig)) &keyset->other_htlc_key, remotesig))
continue; continue;
@ -196,7 +196,7 @@ static bool set_htlc_timeout_fee(struct bitcoin_tx *tx,
type_to_string(tmpctx, struct bitcoin_tx, tx)); type_to_string(tmpctx, struct bitcoin_tx, tx));
bitcoin_tx_output_set_amount(tx, 0, amount); bitcoin_tx_output_set_amount(tx, 0, amount);
elements_tx_add_fee_output(tx); bitcoin_tx_finalize(tx);
return check_tx_sig(tx, 0, NULL, wscript, return check_tx_sig(tx, 0, NULL, wscript,
&keyset->other_htlc_key, remotesig); &keyset->other_htlc_key, remotesig);
} }
@ -240,7 +240,7 @@ static void set_htlc_success_fee(struct bitcoin_tx *tx,
type_to_string(tmpctx, struct amount_sat, &fee), type_to_string(tmpctx, struct amount_sat, &fee),
type_to_string(tmpctx, struct bitcoin_tx, tx)); type_to_string(tmpctx, struct bitcoin_tx, tx));
bitcoin_tx_output_set_amount(tx, 0, amt); bitcoin_tx_output_set_amount(tx, 0, amt);
elements_tx_add_fee_output(tx); bitcoin_tx_finalize(tx);
if (check_tx_sig(tx, 0, NULL, wscript, if (check_tx_sig(tx, 0, NULL, wscript,
&keyset->other_htlc_key, remotesig)) &keyset->other_htlc_key, remotesig))
@ -372,7 +372,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx,
&amt)); &amt));
} }
bitcoin_tx_output_set_amount(tx, 0, amt); bitcoin_tx_output_set_amount(tx, 0, amt);
elements_tx_add_fee_output(tx); bitcoin_tx_finalize(tx);
if (!wire_sync_write(HSM_FD, take(hsm_sign_msg(NULL, tx, wscript)))) if (!wire_sync_write(HSM_FD, take(hsm_sign_msg(NULL, tx, wscript))))
status_failed(STATUS_FAIL_HSM_IO, "Writing sign request to hsm"); status_failed(STATUS_FAIL_HSM_IO, "Writing sign request to hsm");

Loading…
Cancel
Save