tx: Make elements_add_fee_output private

This commit is contained in:
Christian Decker 2020-02-08 21:30:03 +01:00 committed by Rusty Russell
parent 42a63e4416
commit c236bf0fbd
3 changed files with 15 additions and 17 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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");