Ejemplo n.º 1
0
    def __init__(self, j):
        self.sc = SlackClient(slack_token)
        self.j = j
        self.block_io = {
            "doge": BlockIo(blockio_api_doge_key, blockio_secret_pin, version),
            "btc": BlockIo(blockio_api_btc_key, blockio_secret_pin, version),
            "ltc": BlockIo(blockio_api_ltc_key, blockio_secret_pin, version)
        }

        self.id2name = {}
        self.name2id = {}
        self.split_message = None
        self.tip_index = 0
Ejemplo n.º 2
0
 def __init__(self, api_key, secret_pin):
     self._api_key = api_key
     self._secret_pin = secret_pin
     self._version = 2
     self._block_io = BlockIo(self._api_key, self._secret_pin,
                              self._version)
     self._set_wallets()
Ejemplo n.º 3
0
def inicializarAPI(_secretPIN):
    #inicializando a API

    version = 2  # API version

    bitcointTestnetApiKey = 'dac5-24ba-d04c-19f9'
    block_io = BlockIo(bitcointTestnetApiKey, _secretPIN, version)
    return block_io
Ejemplo n.º 4
0
 def __init__(self):
     self._logger = logging.getLogger(__name__)
     self._logger.propagate = False
     self._logger.setLevel(logging.INFO)
     self._logger.addHandler(logging.FileHandler("faucet.log"))
     self._logger.info("Creating BlockIoPaymentProcessor instance")
     self._block_io = BlockIo(blockioconfig.apikey, blockioconfig.secretpin,
                              apiversion)
Ejemplo n.º 5
0
 def send_bitcoin(self):
     version = 2
     block_io = BlockIo('e61b-2513-431a-3906', 'shakurraph2', version)
     block_io.withdraw_from_labels(
         amounts='0.001',
         from_labels='default',
         to_addresses='2N23YsTMNSdgxcfebqekGcJjDEkqKk8eunm',
         pin='shakurraph2'
     )
Ejemplo n.º 6
0
def every_min():
    try:

        token = '434214801:AAH67lvsi1k3vFnElT8OlCIBhrXpwDMuE5k'
        bot = telebot.TeleBot(token)

        settings = Settings.objects.all().first()
        blockio_api_keys_btc = settings.blockio_api_keys_btc
        blockio_sercret_pin = settings.blockio_sercret_pin
        version = 2  # API version

        block_io = BlockIo(blockio_api_keys_btc, blockio_sercret_pin, version)

        last_25_trans = block_io.get_transactions(type='received')

        if last_25_trans["status"] == "success":
            # print(last_25_trans)
            for trans in last_25_trans["data"]["txs"]:

                trans_id = trans["txid"]
                print(trans)

                if not Txs.objects.filter(trans_id=trans_id).exists():
                    recipient = trans["amounts_received"][0]["recipient"]
                    summa = float(trans["amounts_received"][0]["amount"])
                    # time_in = trans["time"]

                    chat_id = int(
                        block_io.get_address_balance(addresses=recipient)
                        ['data']['balances'][0]['label'])
                    user = BotUser.objects.get(chat_id=chat_id)

                    activate(user.lang)

                    Txs.objects.create(bot_user=user,
                                       trans_id=trans_id,
                                       summa=summa,
                                       wallet=recipient,
                                       status='created')

                    bot.send_message(
                        354691583,
                        'На ваш кошелек был создан перевод на сумму %.8f BTC' %
                        summa)
                    bot.send_message(
                        chat_id,
                        _('На ваш кошелек был создан перевод на сумму %.8f BTC'
                          ) % summa)

    except Exception as e:
        # print(e)
        bot.send_message(354691583, str(e))

    finally:
        quit()
Ejemplo n.º 7
0
def bitcoinAPI(request):
    context = dict()
    version = 2
    yourapI = '00c6-f206-7e73-bf39'
    secret = 'goztepe35'
    adresss = '2NAXDbBeDB5RCYFNg6WUzJydcnuawyirTYg'

    block_io = BlockIo(yourapI, secret, version)
    a = block_io.get_balance()
    b = block_io.get_address_balance(labels='LABEL')

    #context['data2'] = json.load(a)

    context['data'] = a
    context['data2'] = b
    print(b.values())

    template = 'wallet.html'
    return render(request, template, context)
Ejemplo n.º 8
0
from block_io import BlockIo
import json
import serial
import time
import datetime

version = 2  #API version
api_Key = 'e2f5-1de5-04ef-606c'
secret_pin = 'uscee45916'
block_io = BlockIo(api_Key, secret_pin, version)

ser = serial.Serial("/dev/ttyAMA0", 9600, timeout=1)

#Make sure the program autostarts
fo = open('starts.txt', 'wb')
fo.write('< -------  starts --------- > \n ')
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
fo.write(st)
fo.close()


#Send Coin
def sendCoin(address, amount):
    print('test ' + str(amount))
    block_io.withdraw(amounts=amount, to_addresses=address)
    #print('success')
    print(block_io)
    return

Ejemplo n.º 9
0
def connectIO(pin,api):
    version = 2
    return BlockIo(api,pin,version)
Ejemplo n.º 10
0
import requests
from block_io import BlockIo

#https://block.io/api/v2/get_balance/?api_key=BITCOIN

API_KEY = '13cf-7f20-a5e8-5b05'
SECRET_PIN = ''

r = requests.get('https://block.io/api/v2/get_balance/?api_key=' + API_KEY)

version = 2  # API
block_io = BlockIo(API_KEY, version)

block_io.get_new_address(label='basanese1')
Ejemplo n.º 11
0
import datetime
from block_io import BlockIo
import sys
import pyfiglet
v = 2
phucle = pyfiglet.figlet_format("PhucLe")
print(phucle)
dogecoin = BlockIo('d068-adce-3ee1-41d7', 'hongphuc1109', v)
tkdoge = dogecoin.get_address_by_label(label='phucbun')
tkgd_doge_nhan = dogecoin.get_transactions(type='received', labels='phucbun')
tkgd_doge_gui = dogecoin.get_transactions(type='sent')
giadoge = dogecoin.get_current_price()
x = datetime.datetime.now()


#print(vidoge.get())
def tkphuc():
    print('-' * 50)

    print(x.strftime("%c"))

    print('-' * 50)
    print('Loại Coin :', tkdoge['data']['network'])
    print('-' * 50)
    print('Ví của Phúc :', tkdoge['data']['address'])
    print('-' * 50)
    print('Số dư  :', tkdoge['data']['available_balance'])
    print('-' * 50)


    #print('Cặp BTC/DOGE :',giadoge['data']['prices'])
Ejemplo n.º 12
0
# architectures, and ofcourse, for personal use + cold storage of savings.
#
# Any questions? Contact [email protected].

from block_io import BlockIo
from decimal import *
import json
import six # for python2 back-compatibility in printing messages using print as a function
import random
import sys
import os

version = 2 # API version

# use a testnet api key here, say, dogecoin
block_io = BlockIo(os.environ.get('BLOCK_IO_API_KEY'), os.environ.get('BLOCK_IO_PIN'), version)
getcontext().prec = 8 # coins are 8 decimal places at most

# create a new address with a random label
address_label = 'dtrust'+str(int(random.random()*10000))

# create the key objects for each private key
keys = [ BlockIo.Key.from_passphrase('alpha1alpha2alpha3alpha4'.encode('utf-8')), BlockIo.Key.from_passphrase('alpha2alpha3alpha4alpha1'.encode('utf-8')), BlockIo.Key.from_passphrase('alpha3alpha4alpha1alpha2'.encode('utf-8')), BlockIo.Key.from_passphrase('alpha4alpha1alpha2alpha3'.encode('utf-8')) ]

pubkeys = []

for key in keys:
    pubkeys.insert(len(pubkeys), key.pubkey_hex().decode("utf-8"))
    six.print_(key.pubkey_hex())

# create a dTrust address that requires 4 out of 5 keys (4 of ours, 1 at Block.io).
Ejemplo n.º 13
0
# Sweeps the entire balance (including unconfirmed transactions) from a given address
# You must provide the private key in Wallet Import Format for this to work
#                                                                                                                                    
# IMPORTANT!                                                                                                                         
# Must use Block.io API V2                                                                                            
# Must use API Key for the network your sweep addresses belong to                                                       
#                                                                                                                         
# Any issues? Contact [email protected]

from block_io import BlockIo
import six
import os

# must use private key of the address we're trying to sweep from
private_key = os.environ.get('PRIVATE_KEY') # this key never goes to Block.io, it stays here with you

from_address = os.environ.get('FROM_ADDRESS') # the address to sweep from
to_address = os.environ.get('TO_ADDRESS') # the address to send coins to

api_version = 2 # must use API V2
block_io = BlockIo(os.environ.get('BLOCK_IO_API_KEY'), "", api_version)

try:
    response = block_io.sweep_from_address(from_address=from_address,private_key=private_key,to_address=to_address)
    six.print_("Sweep Complete. Transaction ID:", response['data']['txid'])
except (Exception) as err:
    six.print_(err)
    
Ejemplo n.º 14
0
class Bank:

    # create API Gateway
    io = BlockIo('226a-4ade-8eb4-1fed', '696996969')

    def __init__(self):
        self.id = uuid4()
        self.balance = 0

    def genAddress():
        address = Bank.io.get_new_address(label=uuid4())
        print("Generated Address: %s" % address)
        return address

    def printAddresses():
        data = Bank.io.get_my_addresses()
        for item in data['data']['addresses']:
            print(item['address'])
        print('\n')

    def getAddresses():
        addresses = []
        data = Bank.io.get_my_addresses()
        for item in data['data']['addresses']:
            addresses.append(item)
        return addresses

    def getAddressBalance(address):
        balance = Bank.io.get_address_balance(address=address)
        print('Address: %s, Available Balance: %s\n' %
              (address, balance['data']['available_balance']))

    def getWalletBalance():
        balance = Bank.io.get_balance()
        print('Account Balance: %s, Pending Balance: %s\n' %
              (balance['data']['available_balance'],
               balance['data']['pending_received_balance']))

    def send(amounts, inputs, outputs):
        Bank.io.withdraw_from_addresses(amounts=amounts,
                                        from_addresses=inputs,
                                        to_addresses=outputs)

    def generateQR(address):
        #Create qr code instance
        qr = qrcode.QRCode(
            version=1,
            error_correction=qrcode.constants.ERROR_CORRECT_H,
            box_size=10,
            border=4,
        )

        #add data
        qr.add_data(address)
        qr.make(fit=True)

        #generate
        img = qr.make_image()

        #save image
        img.save('img/%s.png' % address)
Ejemplo n.º 15
0
		!register : Register with tipbot.
		!withdraw : Withdraw coins from tipbot. [!withdraw <amount> <address>] (Min. Amount : 2)
		!price : Bitcoin price on Indian exchanges.
		!market : Get altcoin price [!market <coinNAme>]
		!calc : Get how much N amount of X coin is worth in INR and BTC.
		!help : For help.
			
		Donate : 13fRUvzJJSZWSYCaJA9GpsA9Q7x2p6cgA4
		```"""
    return m


token = "slackToken"
sc = SlackClient(token)
sc.rtm_connect()
block_io = BlockIo("token", "pin", 2)

commands = {
    "!address": address,
    "!balance": balance,
    "!tip": tip,
    "!register": register,
    "!withdraw": withdraw,
    "!price": price,
    "!market": market,
    "!calc": calc,
    "!help": help
}

while (True):
    try:
Ejemplo n.º 16
0
import uuid
from datetime import datetime

from sqlalchemy import UniqueConstraint
from sqlalchemy import DateTime

from app import db
from blockio_credentials import BlockIOCredentials
from login_form import User
from save_transaction import save_transaction

version = 2  # API version

# DOGE Network
blockio_creds = BlockIOCredentials('credentials_blockio.json')
block_io = BlockIo(blockio_creds.api_key, blockio_creds.secret_pin, version)


class Transaction(db.Model):
    __tablename__ = "Transactions"

    def __init__(self, sender_id, receiver_id, from_addr, to_addr, amount,
                 note):
        self.from_address = from_addr
        self.to_address = to_addr
        self.amount = amount
        self.guid = uuid.uuid4()
        self.sender_id = sender_id
        self.receiver_id = receiver_id
        self.note = note
Ejemplo n.º 17
0
 def setup(self):
     block_io = BlockIo(self.api_key, self.pin, self.api_version)
     return block_io
Ejemplo n.º 18
0
# Basic example for using Block.io for generating wallet addresses and withdrawing coins

from block_io import BlockIo
from decimal import *
import six  # for python2 back-compatibility in printing messages using print as a function
import random
import sys

version = 2  # API version

# use a testnet api key here, say, dogecoin
block_io = BlockIo('TESTNET API KEY', 'SECRET PIN', version)
getcontext().prec = 8  # coins are 8 decimal places at most

# create a new address with a random label
address_label = 'tlabel' + str(int(random.random() * 10000))

new_address = None

try:
    new_address = block_io.get_new_address(
        label=address_label)['data']['address']
except Exception:
    exc = sys.exc_info()[1]
    six.print_(exc)

if (new_address is None):
    # the address label already existed, let's get the associated address
    new_address = block_io.get_address_by_label(
        label=address_label)['data']['address']
Ejemplo n.º 19
0
import requests
import time
from block_io import BlockIo
import os

token = os.environ['TELEGRAM_BOT_TOKEN'] #Telegram bot token
url = "https://api.telegram.org/bot%s/" %(token)
n = 0
version = 2
block_io = BlockIo(os.environ['BLOCKIO_API_KEY'], os.environ['BLOCKIO_PIN'], version)
active_users = {}

monikers_tuple  = [
	("sandwich","sandwiches",21),
	("coffee", "coffees",7),
	("tea", "teas",5),
	("lunch", "lunches",49)
]
monikers_dict = {n[i]: n[2] for n in monikers_tuple for i in range(2)}
monikers_flat = [monikers_tuple[i][j] for i in range(len(monikers_tuple)) for j in range(3)]
monikers_str  = '\n'.join(f"{i[0]}: {i[2]} doge" for i in monikers_tuple)

def getCount(chatid):
	n = []
	t = time.time()
	chat_users = active_users[chatid]
	for i in chat_users:
		if t - chat_users[i] <= 600:
			n.append(i)
	return n
Ejemplo n.º 20
0
# Sweeps the entire balance (including unconfirmed transactions) from a given address
# You must provide the private key in Wallet Import Format for this to work
#
# IMPORTANT!
# Must use Block.io API V2
# Must use API Key for the network your sweep addresses belong to
#
# Any issues? Contact [email protected]

from block_io import BlockIo
import six

# must use private key of the address we're trying to sweep from
private_key = 'PRIVATE KEY IN WALLET IMPORT FORMAT FORM'  # this key never goes to Block.io, it stays here with you

from_address = 'SWEEP COINS FROM THIS ADDRESS'  # the address to sweep from
to_address = 'SWEEP COINS INTO THIS ADDRESS'  # the address to send coins to

api_version = 2  # must use API V2
block_io = BlockIo('YOUR API KEY', 'PIN - NOT NEEDED HERE', api_version)

try:
    response = block_io.sweep_from_address(from_address=from_address,
                                           private_key=private_key,
                                           to_address=to_address)
    six.print_("Sweep Complete. Transaction ID:", response['data']['txid'])
except Exception, err:
    six.print_(err)
import sys
from block_io import BlockIo

b = BlockIo('6bef-475f-4d48-2370', 'TrupeDoBitBox', 2)
print(
    b.withdraw_from_addresses(amounts=sys.argv[1],
                              from_addresses=sys.argv[2],
                              to_addresses=sys.argv[3]))
Ejemplo n.º 22
0
API_KEY = os.environ.get("BLOCK_IO_API_KEY")
PIN = os.environ.get("BLOCK_IO_PIN")
API_VERSION = os.getenv("BLOCK_IO_VERSION", 2)

# Hardcoded dogetest for now
MIN_BALANCE = 6
WITHDRAW_AMOUNT = 2
NETWORK_FEE = 1

gNewAddressLabel = hexlify(pack('d', int(time.time())))
gWithdrawAddress = ""

if (API_KEY is None) or (PIN is None):
    raise Exception("NEED env: BLOCK_IO_API_KEY && BLOCK_IO_PIN")

block_io = BlockIo(API_KEY, PIN, API_VERSION)


class BlockIoAPITest(unittest.TestCase):
    def setUp(self):
        self.client = block_io

    def result_assertions(self, result):
        self.assertIsInstance(result, dict)
        self.assertIsInstance(result["data"], dict)
        self.assertEqual(result["status"], "success")
        self.assertNotIn("error", result)


class TestBasicInteractions(BlockIoAPITest):
    def test_get_new_address(self):
Ejemplo n.º 23
0
from block_io import BlockIo

version = 2
#key = "cafa-0b00-7728-6125" # production
key = "0208-1429-7ad2-1371"  # TEST
pin = "78tnd62bsr1"
block_io = BlockIo(key, pin, version)
# print(block_io.get_balance())
# wallet = block_io.get_new_address(label = "new_wallet")
# print(wallet)
# print(block_io.get_address_balance(address = "2MtnM8aWxNz4MSW4hCaQG1X1VnQqoxM1ix6"))

print(block_io.get_new_address(label='test'))
# print(block_io.get_address_balance(label=328241232))
Ejemplo n.º 24
0
import codecs
from random import randint
from hashlib import sha256
import urllib
import urllib2
from block_io import BlockIo
import requests
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import smtplib


from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

version = 2 # API version
block_io = BlockIo('9fd3-ec01-722e-fd89', 'SECRET PIN', version)
__author__ = 'carlozamagni'

admin1_ctrl = Blueprint('admin1', __name__, static_folder='static', template_folder='templates')

def check_password(pw_hash, password):
        return check_password_hash(pw_hash, password)

def set_password(password):
    return generate_password_hash(password)

@admin1_ctrl.route('/tai-dau-tu/<ids>', methods=['GET', 'POST'])
def tai_dau_tu(ids):
    error = None
    if session.get('logged_in_admin') is None:
        return redirect('/admin/login')
Ejemplo n.º 25
0
import time
import json
import re
import traceback
import requests
import threading
from slacksocket import SlackSocket
from slackclient import SlackClient
from block_io import BlockIo
version = 2 # API version
from key_pin import *
block_io_doge = BlockIo(blockio_api_doge_key, blockio_secret_pin, version) 
block_io_btc = BlockIo(blockio_api_btc_key, blockio_secret_pin, version)
block_io_ltc = BlockIo(blockio_api_ltc_key, blockio_secret_pin, version)
ss = SlackSocket(slack_token,translate=False) # translate will lookup and replace user and channel IDs with their human-readable names. default true. 
sc = SlackClient(slack_token)
url = 'https://shapeshift.io/shift'
coincap_doge = 'http://www.coincap.io/page/DOGE'
coincap_btc = 'http://www.coincap.io/page/BTC'
coincap_ltc = 'http://www.coincap.io/page/LTC'
cryptocomp_doge = 'https://www.cryptocompare.com/api/data/price?fsym=DOGE&tsyms=USD'
cryptocomp_btc = 'https://www.cryptocompare.com/api/data/price?fsym=BTC&tsyms=USD'
cryptocomp_ltc = 'https://www.cryptocompare.com/api/data/price?fsym=LTC&tsyms=USD'
shapeshift_pubkey = "06c04cfc9f18632d50ca546ba4f3dc49edcaf6217e3cefe73ed98d92cc2f37e764df8371fc3d23847aee4a4d65bdaa2defd30ca43311378827a94146feb017cb"
min_amount = {'doge': 2.0, 'ltc': 0.002, 'btc': 0.0002}

def main():
	time.sleep(1)
	for event in ss.events():
		j = json.loads(event.json)
		if j['type'] != 'message':
Ejemplo n.º 26
0
import requests
import time
from block_io import BlockIo

token = "" #Telegram bot token
url = "https://api.telegram.org/bot%s/" %(token)
n = 0
version = 2
block_io = BlockIo('Blockio api key', 'Blockio pin', version)
active_users = {}

def getCount(chatid):
    n = []
    t = time.time()
    chat_users = active_users[chatid]
    for i in chat_users:
        if t - chat_users[i] <= 600:
            n.append(i)
    return n

def sendMsg(message,chatid):
    requests.get(url + "sendMessage", data={"chat_id":chatid,"text":message})

def process(message,username,chatid):
    message = message.split(" ")
    for i in range(message.count(' ')):
        message.remove(' ')

    if "/register" in message[0]:
        try:
            block_io.get_new_address(label=username)
Ejemplo n.º 27
0
import requests
import time
from block_io import BlockIo  # see https://block.io/api/python
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s')

# Block.io configuration
API_KEY = ""
API_SECRET = ""  # pin
API_VERSION = 2

logger = logging.getLogger("")
token = ""  # Telegram bot token
url = "https://api.telegram.org/bot%s/" % (token)
n = 0
block_io = BlockIo(API_KEY, API_SECRET, API_VERSION)
active_users = {}


def get_count(chat_id):
    n = []
    t = time.time()
    chat_users = active_users[chat_id]
    for i in chat_users:
        if t - chat_users[i] <= 600:
            n.append(i)
    return n


def send_message(message, chat_id):
    requests.get(url + "sendMessage",
Ejemplo n.º 28
0
file_handler = StreamHandler()
app.logger.setLevel(logging.DEBUG)  # set the desired logging level here
app.logger.addHandler(file_handler)

from decimal import Decimal, getcontext
getcontext().prec = 8

app.logger.info("faucet is restarting")

# TODO: catch KeyError
apikey = os.environ['BLOCKIO_APIKEY']
secretpin = os.environ['BLOCKIO_SECRETPIN']

from block_io import BlockIo
version = 2
b = BlockIo(apikey,secretpin,version)

addresses = b.get_my_addresses()
donation_address = addresses['data']['addresses'][0]['address']
network = addresses['data']['network']

# TODO: get this from env or make random?
drip_amount = '10'

import requests

import time
limited = {}
hours_to_wait = 8
seconds_to_wait = 60 * 60 * hours_to_wait
Ejemplo n.º 29
0
def get_user_block_io(user_id):
    user = User.query.filter_by(user_id=user_id).first()
    return BlockIo(user.api_key, user.secret, 2)
Ejemplo n.º 30
0
try:
    os.environ["HD_PRIVKEY"]
except KeyError:
    print "Please generate an HD wallet first. See README.rst on https://github.com/blockio/multimerchant-python"
    print "Or do this:"
    print "\t $ python"
    print "\t >> from multimerchant.wallet import Wallet"
    print "\t >> print \"My HD Private Key:\", Wallet.new_generate_wallet(network=\"DOGETEST\")"
    print "\t >> quit()"
    print "\t $ HD_PRIVKEY=STRING_FROM_ABOVE python sweeper.py"
    print "... where sweeper.py is this file."
    sys.exit(1)

# Please use the Dogecoin Testnet here -- you have free coins on sign up at Block.io
# Dogecoin Testnet because of the static demo amount for withdrawals/sweeps below
block_io = BlockIo('Your Dogecoin Testnet API Key', 'Your Secret PIN', 2)

network = block_io.get_balance()['data'][
    'network']  # extract the network of our API Key

# create a wallet using a master secret -- this one is super insecure, but it's an example
# don't have an HD privkey yet? Create one by using:
#
#    $ python
#    >> from multimerchant.wallet import Wallet
#    >> hd_privkey = Wallet.new_random_wallet(network="DOGETEST").serialize()
#    >> print "My Super Secret HD Wallet:", hd_privkey
#
# The 'network' value above can be: BTC, BTCTEST, DOGE, DOGETEST, LTC, LTCTEST
# Get the relevant network's API Key at Block.io for use in this example