MCPcopy Create free account
hub / github.com/ElementsProject/lightning / elements_tx_add_fee_output

Function elements_tx_add_fee_output

bitcoin/tx.c:157–178  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

155 * transactions.
156 */
157static int elements_tx_add_fee_output(struct bitcoin_tx *tx)
158{
159 struct amount_sat fee = bitcoin_tx_compute_fee(tx);
160 int pos;
161
162 /* If we aren't using elements, we don't add explicit fee outputs */
163 if (!chainparams->is_elements)
164 return -1;
165
166 /* Try to find any existing fee output */
167 for (pos = 0; pos < tx->wtx->num_outputs; pos++) {
168 if (elements_tx_output_is_fee(tx, pos))
169 break;
170 }
171
172 if (pos == tx->wtx->num_outputs)
173 return bitcoin_tx_add_output(tx, NULL, NULL, fee);
174 else {
175 bitcoin_tx_output_set_amount(tx, pos, fee);
176 return pos;
177 }
178}
179
180void bitcoin_tx_set_locktime(struct bitcoin_tx *tx, u32 locktime)
181{

Callers 1

bitcoin_tx_finalizeFunction · 0.85

Calls 4

bitcoin_tx_compute_feeFunction · 0.85
bitcoin_tx_add_outputFunction · 0.85

Tested by

no test coverage detected