Example #1
0
def transaction_input(network, txid, index_n):
    if not check_txid(txid) or not index_n.isdigit():
        flash(_('Invalid transaction ID or input number'), category='error')
        return redirect(url_for('main.index'))
    srv = SmurferService(network)
    t = srv.gettransaction(txid)
    if not t:
        flash(_('Transaction %s not found' % txid), category='error')
        return redirect(url_for('main.index'))
    if int(index_n) > len(t.inputs):
        flash(_('Transaction input with index number %s not found' % index_n),
              category='error')
        return redirect(url_for('main.transaction', network=network,
                                txid=txid))
    input = t.inputs[int(index_n)]
    locking_script_op = ''
    locking_script_dict = ''
    unlocking_script_op = ''
    unlocking_script_dict = ''
    try:
        locking_script_op = script_to_string(input.unlocking_script_unsigned,
                                             name_data=True)
    except:
        pass
    try:
        locking_script_dict = script_deserialize(
            input.unlocking_script_unsigned)
    except:
        pass
    try:
        unlocking_script_op = script_to_string(input.unlocking_script,
                                               name_data=True)
    except:
        pass
    try:
        unlocking_script_dict = script_deserialize(input.unlocking_script)
    except:
        pass

    return render_template('explorer/transaction_input.html',
                           title=_('Transaction Input %s' % index_n),
                           subtitle=txid,
                           transaction=t,
                           network=network,
                           input=input,
                           index_n=index_n,
                           locking_script_op=locking_script_op,
                           locking_script_dict=locking_script_dict,
                           unlocking_script_op=unlocking_script_op,
                           unlocking_script_dict=unlocking_script_dict)
Example #2
0
def transaction_output(network, txid, output_n):
    if not check_txid(txid) or not output_n.isdigit():
        flash(_('Invalid transaction ID or output number'), category='error')
        return redirect(url_for('main.index'))
    srv = SmurferService(network)
    t = srv.gettransaction(txid)
    for n, o in enumerate(t.outputs[:5]):
        if o.spent is None:
            o.spent = srv.isspent(t.txid, n)
    if not t:
        flash(_('Transaction %s not found' % txid), category='error')
        return redirect(url_for('main.index'))
    if int(output_n) > len(t.outputs):
        flash(_('Transaction output with index number %s not found' %
                output_n),
              category='error')
        return redirect(url_for('main.transaction', network=network,
                                txid=txid))
    output = t.outputs[int(output_n)]
    locking_script_op = ''
    locking_script_dict = ''
    try:
        locking_script_op = script_to_string(output.lock_script,
                                             name_data=True)
    except:
        pass
    try:
        locking_script_dict = script_deserialize(output.lock_script)
    except:
        pass
    return render_template('explorer/transaction_output.html',
                           title=_('Transaction Output %s' % output_n),
                           subtitle=txid,
                           transaction=t,
                           network=network,
                           output=output,
                           output_n=output_n,
                           locking_script_dict=locking_script_dict,
                           locking_script_op=locking_script_op)
Example #3
0
rt += '44'  # DER encoded Signature - Length
rt += '02'  # DER encoded Signature - Integer
rt += '20'  # DER encoded Signature - Length of X:
rt += '1f6e18f4532e14f328bc820cb78c53c57c91b1da9949fecb8cf42318b791fb38'
rt += '02'  # DER encoded Signature - Integer
rt += '20'  # DER encoded Signature - Lenght of Y:
rt += '45e78c9e55df1cf3db74bfd52ff2add2b59ba63e068680f0023e6a80ac9f51f4'
rt += '01'  # SIGHASH_ALL
# - INPUT: PUBLIC KEY -
rt += '21'  # PUSHDATA 21 - Push following 21 bytes public key to stack:
rt += '0239a18d586c34e51238a7c9a27a342abfb35e3e4aa5ac6559889db1dab2816e9d'
rt += 'feffffff'  # Sequence
# --- OUTPUTS ---
rt += '02'  # Number of outputs
rt += '3ef5980400000000'  # Output value in Little Endian format
rt += '19'  # Script length, of following scriptPubKey:
rt += '76a914af8e14a2cecd715c363b3a72b55b59a31e2acac988ac'
rt += '90940d0000000000'  # Output value #2 in Little Endian format
rt += '19'  # Script length, of following scriptPubKey:
rt += '76a914f0d34949650af161e7cb3f0325a1a8833075165088ac'
rt += 'b7740f00'  # Locktime

print("\nImport and deserialize raw transaction")
t = Transaction.import_raw(rt)
pprint(t.as_dict())
output_script = t.outputs[0].lock_script
print("\nOutput 1st Script Type: %s " %
      script_deserialize(output_script)['script_type'])
print("Output 1st Script String: %s" % script_to_string(output_script))
print("\nt.verified() ==> %s" % t.verify())