示例#1
0
    def get(self, request):
        try:

            srv = Service(providers=['blockchair'])
            print(srv.estimatefee(5))
            print('fee created')

            print('wallet starts')
            srv = LitecoindClient()
            print(srv.estimatefee(5))
            print('litecoin fee created')

            print('new adress', srv.getnewaddress())

            # tx = srv.getutxos('LbLCMRq2oiNgxxesrg7SoCBAMsAAMTqmB9')

            print('wallet starts')
            srv = BitcoindClient()
            print(srv.estimatefee(5))
            print('bitcoin fee created')

            print('bitcoin new adress', srv.getnewaddress())

            print('wallet created in local')
            db_uri = 'postgresql://*****:*****@localhost:5432/altcoin'
            w = wallet_create_or_open('wallet_mysql3', db_uri=db_uri)
            print('wallet created in remote')
            # w = HDWallet.create('Walletmsql1',)
            print('wallet created')
        except Exception:
            track = traceback.format_exc()
            print('-------track start--------')
            print(track)
            print('-------track end--------')

            return HttpResponse(status=404)
        return JsonResponse('', status=400, safe=False)
示例#2
0
    total_amount = 0
    denominator = float(network_obj.denominator)
    for o in outputs:
        nk = wallet.new_key(account_id=OUTPUT_ACCOUNT_ID,
                            name=o['name'].lstrip())
        output_keys.append(nk)
        amount = int(o['amount'] * (1 / denominator))
        outputs_arr.append((nk.address, amount))
        total_amount += amount

    # --- Estimate transaction fees ---
    srv = Service(network=network)
    if args.fee_per_kb:
        fee_per_kb = args.fee_per_kb
    else:
        fee_per_kb = srv.estimatefee()
        if not srv.results:
            raise IOError(
                "No response from services, could not determine estimated transaction fees. "
                "You can use --fee-per-kb option to determine fee manually and avoid this error."
            )
    tr_size = 100 + (1 * 150) + (len(outputs_arr) * 50)
    estimated_fee = int((tr_size / 1024) * fee_per_kb)
    if estimated_fee < 0:
        raise IOError(
            "No valid response from any service provider, could not determine estimated transaction fees. "
            "You can use --fee-per-kb option to determine fee manually and avoid this error."
        )
    print("Estimated fee is for this transaction is %s (%d satoshis/kb)" %
          (network_obj.print_value(estimated_fee), fee_per_kb))
    print("Total value of outputs is %s" %
示例#3
0
# -*- coding: utf-8 -*-
#
#    BitcoinLib - Python Cryptocurrency Library
#
#    EXAMPLES - Creating and Using Cryptocurrency Wallets
#
#    © 2017 November - 1200 Web Development <http://1200wd.com/>
#

from pprint import pprint

from bitcoinlib.services.services import Service

# Tests for specific provider
srv = Service(network='bitcoin', providers=['coinfees'])
print("Estimated bitcoin transaction fee:", srv.estimatefee(3))

# Get Balance and UTXO's for given bitcoin testnet3 addresses
address = 'mqR6Dndmez8WMpb1hBJbGbrQ2mpAU73hQC'
srv = Service(network='testnet', min_providers=5)
print("Balance of address %s: %s" % (address, srv.getbalance(address)))
print("\nAll results as dict:")
pprint(srv.results)
print("\nUTXOs list:")
pprint(srv.getutxos(address))

# GET Raw Transaction data for given Transaction ID
t = 'd3c7fbd3a4ca1cca789560348a86facb3bb21dcd75ed38e85235fb6a32802955'
print("\nGET Raw Transaction:")
pprint(Service(network='testnet', min_providers=2).getrawtransaction(t))
示例#4
0
            print(
                "Install qr code module to show QR codes: pip install pyqrcode"
            )
        clw_exit()
    if args.scan:
        print("Scanning wallet: updating addresses, transactions and balances")
        print("Can take a while")
        wlt.scan()
        print("Scanning complete, show wallet info")
        wlt.info()
        clw_exit()
    if args.create_transaction:
        fee = args.fee
        if not fee:
            srv = Service(network=args.network)
            fee = srv.estimatefee()
        wt = create_transaction(wlt, args.create_transaction, fee)
        wt.sign()
        print("Transaction created")
        wt.info()
        if args.push:
            wt = wt.send()
            print("Send transaction result: %s" % wt)
        else:
            print(
                "Transaction not send yet. Raw transaction to analyse or send online: ",
                wt.raw_hex())
        clw_exit()

    print("Updating wallet")
    wlt.utxos_update()