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

Function elements_tx_add_fee_output

bitcoin/tx.c:167–188  ·  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

165 * transactions.
166 */
167static int elements_tx_add_fee_output(struct bitcoin_tx *tx)
168{
169 struct amount_sat fee = bitcoin_tx_compute_fee(tx);
170 int pos;
171
172 /* If we aren't using elements, we don't add explicit fee outputs */
173 if (!chainparams->is_elements)
174 return -1;
175
176 /* Try to find any existing fee output */
177 for (pos = 0; pos < tx->wtx->num_outputs; pos++) {
178 if (elements_tx_output_is_fee(tx, pos))
179 break;
180 }
181
182 if (pos == tx->wtx->num_outputs)
183 return bitcoin_tx_add_output(tx, NULL, NULL, fee);
184 else {
185 bitcoin_tx_output_set_amount(tx, pos, fee);
186 return pos;
187 }
188}
189
190void bitcoin_tx_set_locktime(struct bitcoin_tx *tx, u32 locktime)
191{

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