예제 #1
0
def test_sendcrypto_success():
    coin = coins['SAFE']
    api = API.get_current_definition(coin)
    send_url = '{}/tx/send'.format(api['url'])
    address_url = '{}/addr/{}/utxo'.format(
        api['url'], 'Rt2NesjPyEEDrHiC5xtYus9tBJTgdtWBfM')
    responses.add(responses.GET, address_url, json=data, status=200)
    responses.add(
        responses.POST,
        send_url,
        json={
            'txid':
            '904c6c12dcd011b30079c3a8646fa744b4d3da0a27f3e67194287a0d0b3bd689'
        },
        content_type='application/json',
        status=200,
    )

    res = send_from_private_keys(
        coin=coins['SAFE'],
        wif_private_keys=[
            'Uy3kRcw1mKVCecWBasE7BEhkirVEtmLQcJ5JyCZMnQkah7X263R6'
        ],
        input_addresses=None,
        unlocking_scripts=None,
        destination_address='Rt2NesjPyEEDrHiC5xtYus9tBJTgdtWBfM',
        satoshis=100000000000,
        fee=10000,
        minimum_input_threshold=20000000000,
        maximum_input_threshold=60000000000,
        limit_inputs=250,
    )

    assert res == '{"txid": "904c6c12dcd011b30079c3a8646fa744b4d3da0a27f3e67194287a0d0b3bd689"}'
예제 #2
0
def test_sendcrypto_success(sys_stdout):
    coin = coins['HUSH']
    api = API.get_current_definition(coin)
    send_url = '{}/tx/send'.format(api['url'])
    address_url1 = '{}/addr/{}/utxo'.format(
        api['url'], 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt')
    address_url2 = '{}/addr/{}/utxo'.format(
        api['url'], 't1TJ7cjWWBxozgekVWVKzCCXKhK4F59v4HB')

    responses.add(
        responses.GET,
        address_url1,
        json=[{
            'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
            'txid':
            'ff269d70ad429f2f3b8e042cf88f76c2f8a9e10de67f626fce25784fc29adb1e',
            'scriptPubKey':
            '76a914fa20c5e0689b92014ac4c3ecfc94b5163eaca3ae88ac',
            'amount': 0.49999,
            'satoshis': 49999000,
            'height': 326169,
            'vout': 0,
            'confirmations': 100
        }],
        status=200)
    responses.add(
        responses.GET,
        address_url2,
        json=[{
            'address': 't1TJ7cjWWBxozgekVWVKzCCXKhK4F59v4HB',
            'txid':
            'e2860bc090fecbe97ebafae2a31c9d9df4aca221002fc8c57d75c5a2ac58af51',
            'scriptPubKey':
            '76a914675bd5240d72cb96e7722b0785ccc60cb168b7ad88ac',
            'amount': 0.01,
            'satoshis': 1000000,
            'height': 326168,
            'vout': 1,
            'confirmations': 102
        }],
        status=200)
    responses.add(
        responses.POST,
        send_url,
        json={
            'txid':
            'a9700b6b18559c2ee976c5a7a5b51f1f9b47daacca96148b3b0afd2b0c6da138'
        },
        content_type='application/json',
        status=200)
    main()

    res = '{"txid": "a9700b6b18559c2ee976c5a7a5b51f1f9b47daacca96148b3b0afd2b0c6da138"}\n'
    assert sys_stdout.getvalue() == res
예제 #3
0
def test_checkaddress_success(sys_stdout):
    response_data = [
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': 'ff269d70ad429f2f3b8e042cf88f76c2f8a9e10de67f626fce25784fc29adb1e',
         'scriptPubKey': '76a914fa20c5e0689b92014ac4c3ecfc94b5163eaca3ae88ac', 'amount': 0.49999,
         'satoshis': 49999000, 'height': 326169, 'vout': 0, 'confirmations': 100},
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': '4417d9e022c8f4adf1ef6d9dbad7a1ee0ae44b7eb5cf61e86fd1a0ed22b1c180', 'vout': 0,
         'scriptPubKey': '76a913e90a9fcb81a78aa732c5721cc0ac4ba2075b7588ac',
         'amount': 526.37874459, 'satoshis': 52637874459, 'confirmations': 41130, 'height': 114322},
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': 'da08e8e2e3ba55f9b45ba7f0ca14f96683c3547419fcfe10e6c8ae9f3eebe4cf', 'vout': 0,
         'scriptPubKey': '76a91413e90a9fcb63a78aa732c5753cc0ac4ba2075b7588ac',
         'amount': 250.97513558, 'satoshis': 25097513558, 'height': 123456, 'confirmations': 2},
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': '7c25ea822bbce5916a331f5851eacbc88d50c0f5a3be8a0dcea772f1baa43965', 'vout': 0,
         'scriptPubKey': '76a91413e90a9fcb63a78aa732c5753cc0ac4ba2075b7588ac',
         'amount': 252.52259867, 'satoshis': 25252259867, 'height': 123458, 'confirmations': 16},
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': '22c66de2660bc913d2d6a2a7013a8762e92374fcb34609eb935d7fa4704f3335', 'vout': 6,
         'scriptPubKey': '76a91413e90a9fcb63a78aa732c5753cc0ac4ba2075b7588ac',
         'amount': 118.6299918, 'satoshis': 11862999180, 'height': 143434, 'confirmations': 712},
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': 'aea9cdf0a8210238749cc4257ea05db91ea79f33691d691a859c4036ad529f85', 'vout': 6,
         'scriptPubKey': '76a91413e90a9fcb63a78aa732c5753cc0ac4ba2075b7588ac',
         'amount': 114.01797238, 'satoshis': 11401797238, 'height': 77734, 'confirmations': 80},

    ]
    coin = coins['HUSH']
    api = API.get_current_definition(coin)
    address_url = '{}/addr/{}/utxo'.format(api['url'], 't1cVB16ohqZTScaSeEN2azETd1h4qXpVDnP')
    responses.add(responses.GET, address_url, json=response_data, status=200)

    main()

    res = ('HUSH Address t1cVB16ohqZTScaSeEN2azETd1h4qXpVDnP\n'
           'txid: 4417d9e022c8f4adf1ef6d9dbad7a1ee0ae44b7eb5cf61e86fd1a0ed22b1c180, confirmations: '
           '   41130, satoshis:      52637874459, amount: 526.37874459 HUSH\n'
           'txid: da08e8e2e3ba55f9b45ba7f0ca14f96683c3547419fcfe10e6c8ae9f3eebe4cf, confirmations: '
           '       2, satoshis:      25097513558, amount: 250.97513558 HUSH\n'
           'txid: 7c25ea822bbce5916a331f5851eacbc88d50c0f5a3be8a0dcea772f1baa43965, confirmations: '
           '      16, satoshis:      25252259867, amount: 252.52259867 HUSH\n'
           'txid: 22c66de2660bc913d2d6a2a7013a8762e92374fcb34609eb935d7fa4704f3335, confirmations: '
           '     712, satoshis:      11862999180, amount: 118.62999180 HUSH\n'
           'txid: aea9cdf0a8210238749cc4257ea05db91ea79f33691d691a859c4036ad529f85, confirmations: '
           '      80, satoshis:      11401797238, amount: 114.01797238 HUSH\n'
           '---------------------------------------------------------------------------------------'
           '-----------------------------------------------------\n'
           '        5 inputs                                                                       '
           '          satoshis:     126252444302, amount: 1262.52444302 HUSH\n')
    assert sys_stdout.getvalue() == res
예제 #4
0
def test_sweepaddress_succes(sys_stdout):
    coin = coins['SAFE']
    api = API.get_current_definition(coin)
    send_url = '{}/tx/send'.format(api['url'])
    address_url = '{}/addr/{}/utxo'.format(
        api['url'], 'Rt2NesjPyEEDrHiC5xtYus9tBJTgdtWBfM')

    responses.add(responses.GET, address_url, json=data, status=200)
    responses.add(
        responses.POST,
        send_url,
        content_type='application/json',
        status=200,
        json={
            'txid':
            '480048710f7443a1fbfe9038e846cd8e30a94dde9b3e9f4507fea923f62c662f'
        },
    )
    responses.add(
        responses.POST,
        send_url,
        content_type='application/json',
        status=200,
        json={
            'txid':
            '7c8cfe3ceceba3e03457d62fbcbe272012ecafcd8006e3a4b366efdaf726ac98'
        },
    )
    responses.add(
        responses.POST,
        send_url,
        content_type='application/json',
        status=200,
        json={
            'txid':
            'a6c82d9295579275cc3b7a4ca80210230a104c159818cfd203b71a6370daff62'
        },
    )

    main()

    res = (
        '{"txid": "480048710f7443a1fbfe9038e846cd8e30a94dde9b3e9f4507fea923f62c662f"}\n'
        '{"txid": "7c8cfe3ceceba3e03457d62fbcbe272012ecafcd8006e3a4b366efdaf726ac98"}\n'
        '{"txid": "a6c82d9295579275cc3b7a4ca80210230a104c159818cfd203b71a6370daff62"}\n'
    )
    assert sys_stdout.getvalue() == res
예제 #5
0
def test_checkadress_get_utxo_from_address_failure(get_utxo_mock):
    response_data = [
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt',
         'txid': '22c66de2660bc913d2d6a2a7013a8762e92374fcb34609eb935d7fa4704f3335', 'vout': 6,
         'scriptPubKey': '76a91413e90a9fcb63a78aa732c5753cc0ac4ba2075b7588ac',
         'amount': 118.6299918, 'satoshis': 11862999180, 'height': 143434, 'confirmations': 712},
        {'address': 't1ggACQ3HenPuiwEaL9vBFcDtxQogHvXzvt'}
    ]
    coin = coins['HUSH']
    api = API.get_current_definition(coin)
    address_url = '{}/addr/{}/utxo'.format(api['url'], 't1cVB16ohqZTScaSeEN2azETd1h4qXpVDnP')
    responses.add(responses.GET, address_url, json=response_data, status=200)

    with pytest.raises(Exception) as exc_info:
        main()

    assert str(exc_info.value) == 'Connection error'
    assert get_utxo_mock.called