(moves)
| 192 | |
| 193 | |
| 194 | def extract_utxos(moves): |
| 195 | utxos = {} |
| 196 | for m in moves: |
| 197 | if 'utxo' not in m: |
| 198 | continue |
| 199 | m['utxo_txid'], m['vout'] = m['utxo'].split(':') |
| 200 | txid = m['utxo_txid'] |
| 201 | if txid not in utxos: |
| 202 | utxos[m['utxo_txid']] = [] |
| 203 | |
| 204 | if 'spending_txid' not in m: |
| 205 | utxos[txid].append([m, None]) |
| 206 | else: |
| 207 | evs = utxos[txid] |
| 208 | # it's a withdrawal, find the deposit and add to the pair |
| 209 | for ev in evs: |
| 210 | if ev[0]['vout'] == m['vout']: |
| 211 | ev[1] = m |
| 212 | if ev[0]['output_msat'] != m['output_msat']: |
| 213 | raise ValueError(f'output_msat does not match. expected {ev[0]}. actual {m}') |
| 214 | break |
| 215 | return utxos |
| 216 | |
| 217 | |
| 218 | def print_utxos(utxos): |
no outgoing calls
no test coverage detected