| 5254 | }; |
| 5255 | |
| 5256 | struct wallet_htlc_iter *wallet_htlcs_first(const tal_t *ctx, |
| 5257 | struct wallet *w, |
| 5258 | const struct channel *chan, |
| 5259 | struct short_channel_id *scid, |
| 5260 | u64 *htlc_id, |
| 5261 | int *cltv_expiry, |
| 5262 | enum side *owner, |
| 5263 | struct amount_msat *msat, |
| 5264 | struct sha256 *payment_hash, |
| 5265 | enum htlc_state *hstate) |
| 5266 | { |
| 5267 | struct wallet_htlc_iter *i = tal(ctx, struct wallet_htlc_iter); |
| 5268 | |
| 5269 | if (chan) { |
| 5270 | i->scid = *channel_scid_or_local_alias(chan); |
| 5271 | assert(i->scid.u64 != 0); |
| 5272 | assert(chan->dbid != 0); |
| 5273 | |
| 5274 | i->stmt = db_prepare_v2(w->db, |
| 5275 | SQL("SELECT h.channel_htlc_id" |
| 5276 | ", h.cltv_expiry" |
| 5277 | ", h.direction" |
| 5278 | ", h.msatoshi" |
| 5279 | ", h.payment_hash" |
| 5280 | ", h.hstate" |
| 5281 | " FROM channel_htlcs h" |
| 5282 | " WHERE channel_id = ?")); |
| 5283 | db_bind_u64(i->stmt, 0, chan->dbid); |
| 5284 | } else { |
| 5285 | i->scid.u64 = 0; |
| 5286 | i->stmt = db_prepare_v2(w->db, |
| 5287 | SQL("SELECT channels.scid" |
| 5288 | ", channels.alias_local" |
| 5289 | ", h.channel_htlc_id" |
| 5290 | ", h.cltv_expiry" |
| 5291 | ", h.direction" |
| 5292 | ", h.msatoshi" |
| 5293 | ", h.payment_hash" |
| 5294 | ", h.hstate" |
| 5295 | " FROM channel_htlcs h" |
| 5296 | " JOIN channels ON channels.id = h.channel_id")); |
| 5297 | } |
| 5298 | /* FIXME: db_prepare should take ctx! */ |
| 5299 | tal_steal(i, i->stmt); |
| 5300 | db_query_prepared(i->stmt); |
| 5301 | |
| 5302 | return wallet_htlcs_next(w, i, |
| 5303 | scid, htlc_id, cltv_expiry, owner, msat, |
| 5304 | payment_hash, hstate); |
| 5305 | } |
| 5306 | |
| 5307 | struct wallet_htlc_iter *wallet_htlcs_next(struct wallet *w, |
| 5308 | struct wallet_htlc_iter *iter, |
no test coverage detected