def test_send_money(self): client = Client(api_key, api_secret) # Start with none of the required arguments, and slowly make requests with # an additional required argument, expecting failure until all arguments # are present. send_kwargs = {} required_kwargs = {'to': 'bar', 'amount': '1.0', 'currency': 'USD'} while required_kwargs: with self.assertRaises(ValueError): transaction = client.send_money('foo', **send_kwargs) for key in required_kwargs: send_kwargs[key] = required_kwargs.pop(key) break transaction = client.send_money('foo', **send_kwargs) self.assertIsInstance(transaction, Transaction) self.assertEqual(transaction, mock_item)
def buy_coins(order: BuyOrder): coins = sat_to_coins(order.satoshis) client = Client("4Mf2j413XB7qNl3V", "0e1wuPN2MaDDPTQdZUQMonxLaJ3zSael") pms = client.get_payment_methods() buy = client.buy('2bbf394c-193b-5b2a-9155-3b4732659ede', amount=coins, currency="BTC", payment_method=pms) tx = client.send_money('2bbf394c-193b-5b2a-9155-3b4732659ede', to=order.address, amount=coins, currency='BTC', idem='9316dd16-0c05')
def Send2Address(exchange, wallet, amount, address): print "SENDING %s %s FROM %s TO %s" % (amount, wallet["Symbol"], exchange, address) if exchange.upper() == "CB" or exchange.upper() == "COINBASE": print "Account ID:", wallet["AccountId"] print "Address:", address print "Amount:", amount print "Currency:", wallet["Symbol"] print "idem:", time.time() client = CB_Client(CB_API_KEY, CB_API_SECRET, api_version="2017-05-19") exchange_rates = client.get_exchange_rates() if wallet["Symbol"] == "BCH": fee = 0.0043 * float(exchange_rates["rates"]["BCH"]) if wallet["Symbol"] == "BTC": fee = 5.2975 * float(exchange_rates["rates"]["BTC"]) if wallet["Symbol"] == "ETH": fee = 1.05 * float(exchange_rates["rates"]["ETH"]) if wallet["Symbol"] == "LTC": fee = 0.042 * float(exchange_rates["rates"]["LTC"]) print str(float(amount) - fee) tx = client.send_money(wallet["AccountId"], amount=str(float(amount) - fee), currency=wallet["Symbol"], to=address, type="send") print tx if exchange.upper() == "NZ" or exchange.upper() == "CRYPTOPIA": tx = json.loads( Cryptopia_API_Query("SubmitWithdraw", { "Address": address, "Amount": amount, "Currency": wallet["Symbol"] })) print tx if exchange.upper() == "KC" or exchange.upper() == "KUCOIN": client = KC_Client(KC_API_KEY, KC_API_SECRET) client.create_withdrawal(wallet["Symbol"], amount, address)
print(term.format("Purchase Bitcoin\n", term.Attr.BOLD)) buy_response = client.buy(account_id, amount=bitcoin_amount, currency="BTC", commit=True, payment_method=payment_method_id) print(term.format(buy_response, term.Color.BLUE)) # verify purchase time buy_time = json.loads(buy_response)["data"]["payout_at"] print(term.format("Purchased Bitcoin at " + buy_time + "\n", term.Attr.BOLD)) # send purchased bitcoin to your secret blockchain.info wallet (see secret_wallet.py) print(term.format("Transfer Bitcoin to Secret Wallet\n", term.Attr.BOLD)) transaction_response = client.send_money(account_id, to=bitcoin_address_of_secret_wallet, amount=bitcoin_amount, currency='BTC') print(term.format(transaction_response, term.Color.BLUE)) transaction_id = json.loads(transaction_response)["data"]["id"] transaction_status = json.loads(transaction_response)["data"]["status"] # keep checking until transaction is completed print(term.format("Check Transaction Status\n", term.Attr.BOLD)) while transaction_status != "completed": # check status every 5 seconds time.sleep(5) transaction_response = client.get_transaction(account_id, transaction_id) transaction_status = json.loads(transaction_response)["data"]["status"] print(term.format(transaction_status + "\n", term.Attr.BOLD)) # alert transaction is completed
#Hashing Address if answer == "6": print("Enter Your Bitcoin Address") WalletAddress = input() Hashed = txhash(WalletAddress) print(Hashed) # Sending Bitcoins if answer == "7": client = Client('Your API KEY', 'Your Secret Key') tx = client.send_money('2bbf394c-193b-5b2a-9155-3b4732659ede', to='1AUJ8z5RuHRTqD1eikyfUUetzGmdWLGkpT', amount='0.1', currency='BTC', idem='9316dd16-0c05') # Pushing Transactions to Email if answer == "8": HexTransaction = input("Insert your raw transaction: ") #example: 0100000001fd468e431cf5797b108e4d22724e1e055b3ecec59af4ef17b063afd36d3c5cf6010000008c4930460221009918eee8be186035be8ca573b7a4ef7bc672c59430785e5390cc375329a2099702210085b86387e3e15d68c847a1bdf786ed0fdbc87ab3b7c224f3c5490ac19ff4e756014104fe2cfcf0733e559cbf28d7b1489a673c0d7d6de8470d7ff3b272e7221afb051b777b5f879dd6a8908f459f950650319f0e83a5cf1d7c1dfadf6458f09a84ba80ffffffff01185d2033000000001976a9144be9a6a5f6fb75765145d9c54f1a4929e407d2ec88ac00000000 pushtx.pushtx(HexTransaction) #Sending info to Email if answer == "9": print("Please enter your Email Address: ") EmailAddres = input()