From c236bf0fbde69216de82c1f05f1f0d85d3871852 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 8 Feb 2020 21:30:03 +0100 Subject: [PATCH] tx: Make elements_add_fee_output private --- bitcoin/tx.c | 12 +++++++++++- bitcoin/tx.h | 12 ------------ onchaind/onchaind.c | 8 ++++---- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 8a8d727a0..6ac439d84 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -98,7 +98,17 @@ static struct amount_sat bitcoin_tx_compute_fee(const struct bitcoin_tx *tx) 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); int pos; diff --git a/bitcoin/tx.h b/bitcoin/tx.h index 8c4d62e68..29eeb8974 100644 --- a/bitcoin/tx.h +++ b/bitcoin/tx.h @@ -165,16 +165,4 @@ bool bitcoin_tx_check(const 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 */ diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index b53d1db7a..9209721e0 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -148,7 +148,7 @@ static bool grind_htlc_tx_fee(struct amount_sat *fee, break; 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, &keyset->other_htlc_key, remotesig)) continue; @@ -196,7 +196,7 @@ static bool set_htlc_timeout_fee(struct bitcoin_tx *tx, type_to_string(tmpctx, struct bitcoin_tx, tx)); 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, &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 bitcoin_tx, tx)); 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, &keyset->other_htlc_key, remotesig)) @@ -372,7 +372,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx, &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)))) status_failed(STATUS_FAIL_HSM_IO, "Writing sign request to hsm");