ledger/btc.py
def _packetize_input_for_signing(
        tx_in: tx.TxIn,
        prevout_info: PrevoutInfo) -> List[bytes]:
    '''Turn an input into a set of packets for the last step of signing'''
    chunks = []
    if prevout_info['witness_script'] is None:
        raise ValueError('Packet for signing must have a script')
    script = cast(bytes, prevout_info['witness_script'])
    le_value = rutils.i2le_padded(prevout_info['value'], 8)

    script_len_bytes = tx.VarInt(len(script)).to_bytes()

    # the first packt is the outpoint and value
    chunks.append(b'\x02'  # 02 is ledger-speak for segwit input
                  + tx_in.outpoint.to_bytes()
                  + le_value
                  + script_len_bytes)

    # Chunk into 50-byte chunks
    chunks.extend([script[i:i + 50] for i in range(0, len(script), 50)])

    # append the sequence to the last one
    chunks[-1] = chunks[-1] + tx_in.sequence

    return [_transaction_continue_packet(chunk) for chunk in chunks]
Turn an input into a set of packets for the last step of signing
Turn an input into a set of packets for the last step of signing
Turn an input into a set of packets for the last step of signing
def _packetize_input_for_signing(
        tx_in: tx.TxIn,
        prevout_info: PrevoutInfo) -> List[bytes]:
    chunks = []
    if prevout_info['witness_script'] is None:
        raise ValueError('Packet for signing must have a script')
    script = cast(bytes, prevout_info['witness_script'])
    le_value = rutils.i2le_padded(prevout_info['value'], 8)
    script_len_bytes = tx.VarInt(len(script)).to_bytes()
    chunks.append(b'\x02'  
                  + tx_in.outpoint.to_bytes()
                  + le_value
                  + script_len_bytes)
    chunks.extend([script[i:i + 50] for i in range(0, len(script), 50)])
    chunks[-1] = chunks[-1] + tx_in.sequence
    return [_transaction_continue_packet(chunk) for chunk in chunks]
def _packetize_input_for_signing ( tx_in : tx . TxIn , prevout_info : PrevoutInfo ) -> List [ bytes ] : chunks = [ ] if prevout_info [ 'witness_script' ] is None : raise ValueError ( 'Packet for signing must have a script' ) script = cast ( bytes , prevout_info [ 'witness_script' ] ) le_value = rutils . i2le_padded ( prevout_info [ 'value' ] , 8 ) script_len_bytes = tx . VarInt ( len ( script ) ) . to_bytes ( ) chunks . append ( b'\x02' + tx_in . outpoint . to_bytes ( ) + le_value + script_len_bytes ) chunks . extend ( [ script [ i : i + 50 ] for i in range ( 0 , len ( script ) , 50 ) ] ) chunks [ - 1 ] = chunks [ - 1 ] + tx_in . sequence return [ _transaction_continue_packet ( chunk ) for chunk in chunks ]
Turn an input into a set of packets for the last step of signing
Turn an input into a set of packets for the last step of signing
'''Turn an input into a set of packets for the last step of signing''' # the first packt is the outpoint and value # 02 is ledger-speak for segwit input # Chunk into 50-byte chunks # append the sequence to the last one
tx_in
tx.TxIn
prevout_info
PrevoutInfo