INNER CODE UNIT · Python
smallest_outpoint
BlockstreamResearch/secp256k1-zkp · tools/tests_silentpayments_generate.py:26
def smallest_outpoint(outpoints):
serialized_outpoints = [bytes.fromhex(txid)[::-1] + n.to_bytes(4, 'little') for txid, n in outpoints]
return sorted(serialized_outpoints)[0]
def is_p2tr(s): # OP_1 OP_PUSHBYTES_32 <32 bytes>
return (len(s) == 34) and (s[0] == 0x51) and (s[1] == 0x20)
def get_pubkey_from_input(input_data, pubkey_hex):
"""Extract the correct pubkey for an input, handling NUMS_H filtering and format conversion"""
spk = bytes.fromhex(input_data['prevout']['scriptPubKey']['hex'])
pubkey = bytes.fromhex(pubkey_hex)
if is_p2tr(spk): # taproot input
# Check for NUMS_H in witness (should be skipped)
witness = bytes.fromhex(input_data.get('txinwitness', ''))
# Parse witness stack
witness_stack = []
num_witness_items = 0