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

Function output_spent

onchaind/onchaind.c:1195–1353  ·  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

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