Beispiel #1
0
def unsigned_legacy_tx(tx_ins, tx_outs, **kwargs):
    '''Create an unsigned transaction
    Use this to generate sighashes for unsigned TxIns
    Hint: set version to 2 if using sequence number relative time locks

    Args:
        tx_ins      list(TxIn instances): list of transaction inputs
        tx_outs     list(TxOut instances): list of transaction outputs

        **kwargs:
        version     (int): transaction version number
        locktime            (hex): transaction locktime
        expiry              (int): overwinter expiry time
        tx_joinsplits       (list): list of joinsplits transactions
        joinsplit_pubkey    (bytes): joinsplit public key
        joinsplit_sig       (bytes): joinsplit signature

    Returns:
        (Tx instance): unsigned transaction
    '''
    return tb.make_tx(
        version=kwargs['version'] if 'version' in kwargs else 2,
        tx_ins=tx_ins,
        tx_outs=tx_outs,
        lock_time=kwargs['lock_time'] if 'lock_time' in kwargs else 0,
        expiry=kwargs['expiry'] if 'expiry' in kwargs else 0,
        tx_joinsplits=(kwargs['tx_joinsplits']
                       if 'tx_joinsplits' in kwargs else []),
        joinsplit_pubkey=(kwargs['joinsplit_pubkey']
                          if 'joinsplit_pubkey' in kwargs else []),
        joinsplit_sig=(kwargs['joinsplit_sig']
                       if 'joinsplit_sig' in kwargs else []))
 def test_overwinter_snowflake(self, mock_tx):
     # TODO: Improve
     riemann.select_network('zcash_overwinter_main')
     mock_tx.OverwinterTx.return_value = 0
     self.assertEqual(
         tb.make_tx(0, 0, 0, 0, expiry=0),
         0)
Beispiel #3
0
 def test_make_decred_tx(self):
     riemann.select_network('decred_main')
     helper_witness = helpers.DCR['ser']['witnesses'][0]
     outpoint = tb.make_outpoint(
         tx_id_le=helpers.DCR['ser']['ins'][0]['hash'], index=0, tree=0)
     tx_in, witness = tb.make_witness_input_and_witness(
         outpoint=outpoint,
         sequence=helpers.DCR['human']['ins'][0]['sequence'],
         value=helper_witness['value'],
         height=helper_witness['height'],
         index=helper_witness['index'],
         stack_script=helper_witness['stack_script'],
         redeem_script=helper_witness['redeem_script'])
     tx_out = tb._make_output(
         value=helpers.DCR['ser']['outs'][0]['value'],
         output_script=helpers.DCR['ser']['outs'][0]['pk_script'],
         version=helpers.DCR['ser']['outs'][0]['version'])
     self.assertEqual(
         tb.make_tx(version=1,
                    tx_ins=[tx_in],
                    tx_outs=[tx_out],
                    lock_time=helpers.DCR['human']['locktime'],
                    expiry=helpers.DCR['human']['expiry'],
                    tx_witnesses=witness),
         helpers.DCR['ser']['tx']['p2sh_2_p2pkh'])
 def test_sprout_snowflake(self, mock_tx):
     # TODO: Improve
     riemann.select_network('zcash_sprout_main')
     mock_tx.SproutTx.return_value = 0
     self.assertEqual(
         tb.make_tx(0, 0, 0, 0, tx_joinsplits=[]),
         0)
Beispiel #5
0
def unsigned_witness_tx(tx_ins, tx_outs, **kwargs):
    '''Create an unsigned segwit transaction
    Create an unsigned segwit transaction
    Use this to generate sighashes for unsigned TxIns
    Hint: set version to 2 if using sequence number relative time locks

    Args:
        tx_ins      list(TxIn instances): list of transaction inputs
        tx_outs     list(TxOut instances): list of transaction outputs

        **kwargs:
        version     (int): transaction version number
        locktime    (hex): transaction locktime

    Returns:
        (Tx instance): unsigned transaction with empty witness
    '''
    return tb.make_tx(
        version=kwargs['version'] if 'version' in kwargs else 2,
        tx_ins=tx_ins,
        tx_outs=tx_outs,
        lock_time=kwargs['lock_time'] if 'lock_time' in kwargs else 0,
        tx_witnesses=[tb.make_empty_witness() for _ in tx_ins])