| 408 | |
| 409 | |
| 410 | def check_utxos_channel(n, chans, expected, exp_tag_list=None, filter_channel=None): |
| 411 | tag_list = {} |
| 412 | moves = n.rpc.call('listcoinmoves_plugin')['coin_moves'] |
| 413 | |
| 414 | utxos = extract_utxos(dedupe_moves(moves)) |
| 415 | |
| 416 | if filter_channel: |
| 417 | utxos = utxos_for_channel(utxos, filter_channel) |
| 418 | |
| 419 | # Stash for errors, if we get them |
| 420 | _utxos = utxos |
| 421 | for tag, evs in expected.items(): |
| 422 | if tag not in tag_list: |
| 423 | u_set = list(utxos.values())[0] |
| 424 | elif tag in tag_list: |
| 425 | u_set = utxos[tag_list[tag]] |
| 426 | |
| 427 | txid = matchup_events(u_set, evs, chans, tag_list) |
| 428 | |
| 429 | if tag not in tag_list: |
| 430 | tag_list[tag] = txid |
| 431 | |
| 432 | # Remove checked set from utxos |
| 433 | del utxos[txid] |
| 434 | |
| 435 | # Verify that we went through all of the utxos |
| 436 | if len(utxos) != 0: |
| 437 | raise ValueError(f"leftover utxos? expected: {expected}, actual: {_utxos}") |
| 438 | |
| 439 | # Verify that the expected tags match the found tags |
| 440 | if exp_tag_list: |
| 441 | for tag, txid in tag_list.items(): |
| 442 | if tag in exp_tag_list: |
| 443 | if exp_tag_list[tag] != txid: |
| 444 | raise ValueError(f"expected tags txid {exp_tag_list[tag]} != actual {txid}. expected: {exp_tag_list}, actual: {tag_list}") |
| 445 | |
| 446 | return tag_list |
| 447 | |
| 448 | |
| 449 | def first_channel_id(n1, n2): |