ledger/btc.py
async def _get_sig(
        client: blue.Ledger,
        first_packet: bytes,
        last_packet: bytes,
        tx_in: tx.TxIn,
        prevout_info: PrevoutInfo) -> bytes:
    '''
    Gets a signature for an input
    Args:
        first_packet       (bytes): the first packet e0440000... (input start)
        last_packet        (bytes): the last packet e0480000... (hash sign)
        tx_in            (tx.TxIn): the transaction input
        prevout_info (PrevoutInfo): the script and value of the prevout
    Returns:
        (bytes): the signature, unmasked
    '''
    # for convenience, we do surgery on the packet
    # yes, this is messy. but it's way more straightforward than
    # setting p1 and p2 to 0x0080 means this is a new pseudo-tx continuation
    # setting the second-to-last to 1 to overwrite len(vin)
    first_packet = (first_packet[0:2]
                    + b'\x00\x80'  # overwrite p1+p2
                    + first_packet[4:-2]
                    + b'\x01'      # overwrite len(vin)
                    + first_packet[-1:])

    # they need to be packetized with their witness script
    input_packets = _packetize_input_for_signing(tx_in, prevout_info)

    # Send all the packets and the sig-request packet
    await client.exchange(first_packet)
    for packet in input_packets:
        await client.exchange(packet)
    response = await client.exchange(last_packet)  # request the sig

    # unmask the sig before we return it
    return _unmask_sig(response)

    Gets a signature for an input
    Args:
        first_packet       (bytes): the first packet e0440000... (input start)
        last_packet        (bytes): the last packet e0480000... (hash sign)
        tx_in            (tx.TxIn): the transaction input
        prevout_info (PrevoutInfo): the script and value of the prevout
    Returns:
        (bytes): the signature, unmasked
    
Gets a signature for an input
Gets a signature for an input
async def _get_sig(
        client: blue.Ledger,
        first_packet: bytes,
        last_packet: bytes,
        tx_in: tx.TxIn,
        prevout_info: PrevoutInfo) -> bytes:
    first_packet = (first_packet[0:2]
                    + b'\x00\x80'  
                    + first_packet[4:-2]
                    + b'\x01'      
                    + first_packet[-1:])
    input_packets = _packetize_input_for_signing(tx_in, prevout_info)
    await client.exchange(first_packet)
    for packet in input_packets:
        await client.exchange(packet)
    response = await client.exchange(last_packet)  
    return _unmask_sig(response)
async def _get_sig ( client : blue . Ledger , first_packet : bytes , last_packet : bytes , tx_in : tx . TxIn , prevout_info : PrevoutInfo ) -> bytes : first_packet = ( first_packet [ 0 : 2 ] + b'\x00\x80' + first_packet [ 4 : - 2 ] + b'\x01' + first_packet [ - 1 : ] ) input_packets = _packetize_input_for_signing ( tx_in , prevout_info ) await client . exchange ( first_packet ) for packet in input_packets : await client . exchange ( packet ) response = await client . exchange ( last_packet ) return _unmask_sig ( response )
Gets a signature for an input
Gets a signature for an input
'''
    Gets a signature for an input
    Args:
        first_packet       (bytes): the first packet e0440000... (input start)
        last_packet        (bytes): the last packet e0480000... (hash sign)
        tx_in            (tx.TxIn): the transaction input
        prevout_info (PrevoutInfo): the script and value of the prevout
    Returns:
        (bytes): the signature, unmasked
    ''' # for convenience, we do surgery on the packet # yes, this is messy. but it's way more straightforward than # setting p1 and p2 to 0x0080 means this is a new pseudo-tx continuation # setting the second-to-last to 1 to overwrite len(vin) # overwrite p1+p2 # overwrite len(vin) # they need to be packetized with their witness script # Send all the packets and the sig-request packet # request the sig # unmask the sig before we return it
the signature, unmasked
the signature unmasked
(bytes)
client
blue.Ledger
first_packet
bytes
None
last_packet
bytes
None
tx_in
tx.TxIn
the transaction input
the transaction input
prevout_info
PrevoutInfo
the script and value of the prevout
the script and value of the prevout