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

Function output_spent

onchaind/onchaind.c:1181–1339  ·  view source on GitHub ↗

An output has been spent: see if it resolves something we care about. * Return true if it's useful to know about, false to suppress this and any * child transactions. */

Source from the content-addressed store, hash-verified

1179 * child transactions.
1180 */
1181static bool output_spent(struct tracked_output ***outs,
1182 const struct tx_parts *tx_parts,
1183 u32 input_num,
1184 u32 tx_blockheight)
1185{
1186 bool interesting = false;
1187
1188 for (size_t i = 0; i < tal_count(*outs); i++) {
1189 struct tracked_output *out = (*outs)[i];
1190 struct bitcoin_outpoint htlc_outpoint;
1191
1192 if (!wally_tx_input_spends(tx_parts->inputs[input_num],
1193 &out->outpoint))
1194 continue;
1195
1196 interesting = true;
1197
1198 if (out->resolved)
1199 continue;
1200
1201 /* Was this our resolution? */
1202 if (resolved_by_proposal(out, tx_parts)) {
1203 /* If it's our htlc tx, we need to resolve that, too. */
1204 if (out->resolved->tx_type == OUR_HTLC_SUCCESS_TX
1205 || out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX)
1206 resolve_htlc_tx(outs, i, tx_parts, input_num,
1207 tx_blockheight);
1208
1209 record_coin_movements(out, tx_blockheight,
1210 &tx_parts->txid);
1211 break;
1212 }
1213
1214 htlc_outpoint.txid = tx_parts->txid;
1215 htlc_outpoint.n = input_num;
1216
1217 switch (out->output_type) {
1218 case OUTPUT_TO_US:
1219 case DELAYED_OUTPUT_TO_US:
1220 unknown_spend(out, tx_parts);
1221 record_external_deposit(out, out->tx_blockheight,
1222 mk_mvt_tags(MVT_PENALIZED));
1223 break;
1224
1225 case THEIR_HTLC:
1226 if (out->tx_type == THEIR_REVOKED_UNILATERAL) {
1227 struct mvt_tags tags = mk_mvt_tags(MVT_HTLC_TIMEOUT, MVT_STEALABLE);
1228
1229 record_external_deposit(out, out->tx_blockheight,
1230 tags);
1231 record_external_spend(&tx_parts->txid,
1232 out,
1233 tx_blockheight,
1234 tags);
1235
1236 /* we've actually got a 'new' output here */
1237 steal_htlc_tx(out, outs, tx_parts,
1238 tx_blockheight,

Callers 1

handle_onchaind_spentFunction · 0.85

Calls 15

wally_tx_input_spendsFunction · 0.85
resolved_by_proposalFunction · 0.85
resolve_htlc_txFunction · 0.85
record_coin_movementsFunction · 0.85
unknown_spendFunction · 0.85
record_external_depositFunction · 0.85
record_external_spendFunction · 0.85
steal_htlc_txFunction · 0.85
ignore_outputFunction · 0.85
resolved_by_otherFunction · 0.85

Tested by

no test coverage detected