Exemple #1
0
def GetTransactions():

    #100000000 = 1 BTC
    #currently: 50BTC
    bitcoin = 10000000000  #change this value to capture transfers of specified amount

    #limit 100 is the highest bitcypher api allows you to go
    bitcoin_transactions = get_broadcast_transactions(limit=100)

    transaction_list = []

    for i in bitcoin_transactions:
        try:
            sender = i['inputs'][0]['addresses'][0]
        except KeyError:
            sender = 'None'
        bitcoin_sent = i['inputs'][0]['output_value']
        receiverLen = len(i['outputs'])
        try:
            receiver = i['outputs'][0]['addresses'][0]
        except TypeError:
            receiver = 'None'

        #find the highest receiver of bitcoin transaction
        highest = 0
        receivers = i['outputs']
        for a, i in enumerate(receivers):
            if receiverLen > 1:
                if receivers[a]['value'] > highest:
                    highest = receivers[a]['value']

        if bitcoin_sent > bitcoin:
            transaction_list.append([sender, bitcoin_sent, receiver, highest])

    return transaction_list
Exemple #2
0
    def test_unconfirmed_tx_confidence(self):
        # fetch a recent tx hash (assume BTC will always have an unconfirmed TX):
        recent_tx_hash = get_broadcast_transactions(
            coin_symbol='btc',
            api_key=BC_API_KEY,
            limit=1,
        )[0]['hash']
        # get confidence info for it
        tx_details = get_transaction_details(
            tx_hash=recent_tx_hash,
            coin_symbol='btc',
            limit=1,
            tx_input_offset=None,
            tx_output_offset=None,
            include_hex=False,
            confidence_only=True,
            api_key=BC_API_KEY,
        )

        assert 'receive_count' in tx_details, tx_details
        assert 'preference' in tx_details, tx_details
        assert 'age_millis' in tx_details, tx_details
        assert 'confidence' in tx_details, tx_details
        assert 0 <= tx_details['confidence'] <= 1, tx_details
    def test_unconfirmed_tx_confidence(self):
        # fetch a recent tx hash (assume BTC will always have an unconfirmed TX):
        recent_tx_hash = get_broadcast_transactions(
                coin_symbol='btc',
                api_key=BC_API_KEY,
                limit=1,
                )[0]['hash']
        # get confidence info for it
        tx_details = get_transaction_details(
                tx_hash=recent_tx_hash,
                coin_symbol='btc',
                limit=1,
                tx_input_offset=None,
                tx_output_offset=None,
                include_hex=False,
                confidence_only=True,
                api_key=BC_API_KEY,
                )

        assert 'receive_count' in tx_details, tx_details
        assert 'preference' in tx_details, tx_details
        assert 'age_millis' in tx_details, tx_details
        assert 'confidence' in tx_details, tx_details
        assert 0 <= tx_details['confidence'] <= 1, tx_details
    print("Received: ", result['total_received'], " sat")
    print("Sent: ", result['total_sent'], " sat")
    print("Balance: ", result['balance'], " sat")
    print("Number of Transactions: ", result['n_tx'])
elif choice == 7:
    result = get_wallet_addresses(wallet_name=wallet_Name, api_key=apikey)
    print("Number of addresses associated: ", len(result['addresses']))
elif choice == 8:
    result = get_wallet_addresses(wallet_name=wallet_Name,
                                  api_key=apikey,
                                  is_hd_wallet=True)
    print("Number of addresses associated: ", len(result['addresses']))
elif choice == 9:
    result = get_transaction_details(haash)
    print("Block Height: ", result['block_height'])
    print("Total :", result['total'], " sat")
elif choice == 10:
    result = get_broadcast_transactions(limit=1)
    print("Number of Unconfirmed Transactions: ", len(result))
    print("Transaction Hash: ", result[0]['hash'])
elif choice == 11:
    result = get_transaction_details(haash,
                                     confidence_only=True,
                                     api_key=apikey)
    print("Confidence: ", result['confidence'])
elif choice == 12:
    result = get_metadata(address=address, api_key=apikey)
    print(result)
else:
    print('Thank you !!!')