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

Function matchup_events

tests/utils.py:248–299  ·  view source on GitHub ↗
(u_set, evs, chans, tag_list)

Source from the content-addressed store, hash-verified

246
247
248def matchup_events(u_set, evs, chans, tag_list):
249 assert len(u_set) == len(evs) and len(u_set) > 0
250
251 txid = u_set[0][0]['utxo_txid']
252 for ev in evs:
253 found = False
254 for u in u_set:
255 # We use 'cid' as a placeholder for the channel id, since it's
256 # dyanmic, but we need to sub it in. 'chans' is a list of cids,
257 # which are mapped to `cid` tags' suffixes. eg. 'cid1' is the
258 # first cid in the chans list
259 if ev[0][:3] == 'cid':
260 idx = int(ev[0][3:])
261 acct = chans[idx - 1]
262 else:
263 acct = ev[0]
264
265 if u[0]['account_id'] != acct or u[0]['tags'] != ev[1]:
266 continue
267
268 if ev[2] is None:
269 assert u[1] is None
270 found = True
271 u_set.remove(u)
272 break
273
274 # ugly hack to annotate two possible futures for a utxo
275 if type(ev[2]) is tuple:
276 tag = u[1]['tags'] if u[1] else u[1]
277 assert tag in [x[0] for x in ev[2]]
278 if not u[1]:
279 found = True
280 u_set.remove(u)
281 break
282 for x in ev[2]:
283 if x[0] == u[1]['tags'] and 'to_miner' not in u[1]['tags']:
284 # Save the 'spent to' txid in the tag-list
285 tag_list[x[1]] = u[1]['txid']
286 else:
287 assert ev[2] == u[1]['tags']
288 # Save the 'spent to' txid in the tag-list
289 if 'to_miner' not in u[1]['tags']:
290 tag_list[ev[3]] = u[1]['txid']
291
292 found = True
293 u_set.remove(u)
294
295 assert found
296
297 # Verify we used them all up
298 assert len(u_set) == 0
299 return txid
300
301
302def dedupe_moves(moves):

Callers 1

check_utxos_channelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected