Пример #1
0
def get_input_value(tx_hex):
    unspents = wallet.list_unspent()
    ctx = bitcoinlib.core.CTransaction.deserialize(binascii.unhexlify(tx_hex))
    
    inputs_value = 0
    for vin in ctx.vin:
        vin_tx_hash = ib2h(vin.prevout.hash)
        vout_n = vin.prevout.n
        found = False
        for output in unspents:
            if output['txid'] == vin_tx_hash and output['vout'] == vout_n:
                inputs_value += int(output['amount'] * config.UNIT)
                found = True
        if not found:
            raise exceptions.TransactionError('input not found in wallet list unspents')

    return inputs_value
Пример #2
0
def get_input_value(tx_hex):
    unspents = wallet.list_unspent()
    ctx = bitcoinlib.core.CTransaction.deserialize(binascii.unhexlify(tx_hex))

    inputs_value = 0
    for vin in ctx.vin:
        vin_tx_hash = ib2h(vin.prevout.hash)
        vout_n = vin.prevout.n
        found = False
        for output in unspents:
            if output["txid"] == vin_tx_hash and output["vout"] == vout_n:
                inputs_value += int(output["amount"] * config.UNIT)
                found = True
        if not found:
            raise exceptions.TransactionError("input not found in wallet list unspents")

    return inputs_value