Locate the vout index of the given transaction sending to the given address. Raises runtime error exception if not found.
(node, txid, addr)
| 612 | |
| 613 | |
| 614 | def find_vout_for_address(node, txid, addr): |
| 615 | """ |
| 616 | Locate the vout index of the given transaction sending to the |
| 617 | given address. Raises runtime error exception if not found. |
| 618 | """ |
| 619 | tx = node.getrawtransaction(txid, True) |
| 620 | unblind_addr = addr |
| 621 | if node.getblockchaininfo()['chain'] == 'elementsregtest': |
| 622 | unblind_addr = node.validateaddress(addr)["unconfidential"] |
| 623 | for i in range(len(tx["vout"])): |
| 624 | if tx["vout"][i]["scriptPubKey"]["type"] == "fee": |
| 625 | continue |
| 626 | if unblind_addr == tx["vout"][i]["scriptPubKey"]["address"]: |
| 627 | return i |
| 628 | raise RuntimeError("Vout not found for address: txid=%s, addr=%s" % (txid, addr)) |
| 629 | |
| 630 | def modinv(a, n): |
| 631 | """Compute the modular inverse of a modulo n using the extended Euclidean |
no outgoing calls