Beispiel #1
0
def create_wallet(user_id):
    key = Key()
    current_address = key.address
    current_privkey = key.to_wif()
    cursor.execute(
        "INSERT INTO wallets (user_id, public_address, private_key) values (?, ?, ?)",
        (str(user_id), str(current_address), str(current_privkey)))
    conn.commit()
Beispiel #2
0
def startGenerating(name, caseSens, thread, running):
    timestamp = int(time())
    rate = times = 0

    while True:
        if not running.value:
            sys.exit()

        if int(time()) == timestamp + 1:
            timestamp += 1
            if times < 10: times += 0
            if times == 10:
                print(
                    f'Thread {thread} is generating ~{rate} addresses per second.'
                )
            times += 1
            rate = 0

        rate += 1

        key = Key()
        address = key.address

        if (not caseSens and address[1:len(name) + 1].lower()
                == name.lower()) or (caseSens
                                     and address[1:len(name) + 1] == name):
            privkey = key.to_wif()
            running.value = False
            print('-' * 100)
            print(
                f'''\nAdress successfully generated!\n\nAddress: {address}\nPrivate key: {privkey}\n'''
            )
            print('-' * 100)
            print(
                '\nThe private key gives total access to your coins, so NEVER share it with anyone.'
            )
            print(
                "Store the private key in a safe place IMMEDIATELY.\n\nThanks for using keepler's VanGen.\nYou can contribute to this project at github.com/Keepler/bitcoinvangen"
            )
Beispiel #3
0
 def generate_address(self):
     key = Key()
     return {
         'address': key.address,
         'pri_key': key.to_wif(),
     }
Beispiel #4
0
def new_key():

    key = Key()

    key_obj = {"WIF": key.to_wif(), "address": key.address}
    return key_obj
Beispiel #5
0
# Status: generates private key

from bit import Key, PrivateKey, PrivateKeyTestnet
key = Key()

# Print PrivateKey
print(key)
# Print public point using one way Elliptic key Function
print(key.public_point)
# Print public Key
print(key.public_key)
# Print Sharable Bitcoin address
print(key.address)
# Print export Wallet Import Format Private key
print(key.to_wif())
# Print export private key in hex format
print(key.to_hex())
# Print to be exported private key in integer Format
print(key.to_int())
# Print to be exported private key
print(key.to_pem())
Beispiel #6
0
import time, sys
from bit import Key
from tqdm import tqdm 
print('--')
print(time.ctime(time.time()),'-Begin')  
limi=2500000

fname='100top.txt'
filetext = open(fname).read()

if len(sys.argv)>1:
  limi=int(sys.argv[1])

with tqdm(total=limi) as pbar:
  for i in range(limi):    # 125 sec @ 1000000  7900 addr|sec
    key = Key()
    adr = key.address
#...
    if adr in filetext:
      print("FOUND!!! ",i) 
      print("Addr: ",adr)
      wif = key.to_wif()
      print("WiF: ", wif)
      break
    pbar.update(1)  
  print("..nothing for %s attempts"%(limi),' - top100 wallets checked')
print(time.ctime(time.time()),'-End.')    


# https://ofek.dev/bit/guide/keys.html#creation
# https://bitinfocharts.com/ru/top-100-dormant_5y-bitcoin-addresses.html
Beispiel #7
0
class MainPage(tk.Frame):  
    def __init__(self, parent, controller): 
        tk.Frame.__init__(self, parent)
        
        self.parent = parent
        self.configure(background='white')
        self.currency = 'btc'
        self.trans_url = "https://blockstream.info/testnet/api/tx/"
        
        addressLabel = tk.Label(self, text = "Address: dfsu3fdu434", bg = "white", fg = "black", font = LARGEFONT)
        addressLabel.grid(row = 0, column = 0, columnspan = 2, sticky = W, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        self.coinLabel = tk.Label(self, text = "Coins: 1 btc", bg = "white", fg = "black", font = LARGEFONT)
        self.coinLabel.grid(row = 1, column = 0, columnspan = 2, sticky = W, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        self.sendAddressInput = tk.Entry(self, bg='#ebf3ff', font = LARGEFONT)
        self.sendAddressInput.grid(row = 2, column = 0, sticky = W+E, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        self.sendCoinsInput = tk.Entry(self, bg='#ebf3ff', font = LARGEFONT)
        self.sendCoinsInput.grid(row = 3, column = 0, sticky = W, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        sendButton = tk.Button(self, text = 'Send',
                                fg = 'white',
                                bg = '#8c9fbd',
                                activeforeground = 'white',
                                activebackground = '#b8c2d1',
                                borderwidth = 2,
                                relief = FLAT,
                                overrelief = RAISED,
                                font = LARGEFONT,
                                command = lambda : self.asyncSendCoins())
        sendButton.grid(row = 4, column = 0, sticky = W, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        copyButton = tk.Button(self, text = 'Copy PrivKey to Clipboard',
                                fg = 'white',
                                bg = '#de9ec0',
                                activeforeground = 'white',
                                activebackground = '#de9ec0',
                                borderwidth = 2,
                                relief = FLAT,
                                overrelief = RAISED,
                                font = LARGEFONT,
                                command = lambda : self.copyKey())
        copyButton.grid(row = 4, column = 1, sticky = W, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        self.changeCurrencyInput = tk.Entry(self, bg='#ebf3ff', font = LARGEFONT)
        self.changeCurrencyInput.grid(row = 5, column = 0, sticky = W, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        changeCurrencyButton = tk.Button(self, text = 'Change currency',
                                fg = 'white',
                                bg = '#8c9fbd',
                                activeforeground = 'white',
                                activebackground = '#b8c2d1',
                                borderwidth = 2,
                                relief = FLAT,
                                overrelief = RAISED,
                                font = LARGEFONT,
                                command = lambda : self.asyncChangeCurrency())
        changeCurrencyButton.grid(row = 5, column = 1, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        
        self.transactions = Listbox(self)
        self.transactions.grid(row = 0, column = 2, rowspan = 3, columnspan = 4, sticky = 'nsew')
        self.transactions.bind('<<ListboxSelect>>', self.asynconselect)
        self.transactionsVar = StringVar()
        self.transactionsVar.set(150 * " ")
        self.transactionsLabel = tk.Message(self, textvariable = self.transactionsVar, bg = "white", fg = "black", width = 300)
        self.transactionsLabel.grid(row = 3, column = 2, rowspan = 3, sticky = W+E, columnspan = 4, padx = 10, pady = 10, ipadx = 5, ipady = 5)
        
        self.parent.after(3000, self.asyncUpdateInterface)
        
        if (controller.config.get('istestnet') == 1):
            self.trans_url = "https://blockstream.info/testnet/api/tx/"
            if (controller.config.get('private_key') != None):
                self.key = PrivateKeyTestnet(controller.config.get('private_key'))
            else:
                self.key = PrivateKeyTestnet()
        else:
            self.trans_url = "https://blockstream.info/api/tx/"
            if (controller.config.get('private_key') != None):
                self.key = Key(controller.config.get('private_key'))
            else:
                self.key = Key()
        
        addressLabel.config(text = "Address: " + self.key.address)
        self.coinLabel.config(text = "Coins: " + self.key.get_balance(self.currency) + " " + self.currency)
            
        transactions_list = self.key.get_transactions()
        for trans in transactions_list:
            print(trans)
            self.transactions.insert(END, trans)
        print(self.trans_url)
        for x in range(6):
            Grid.columnconfigure(self, x, weight=1)

        for y in range(5):
            Grid.rowconfigure(self, y, weight=1)
    
    def asyncChangeCurrency(self):
        x = threading.Thread(target = self.changeCurrency)
        x.start()
        
    def changeCurrency(self):
        cur_values = dict(SUPPORTED_CURRENCIES).keys()
        us_input = self.changeCurrencyInput.get()
        self.changeCurrencyInput.delete(0, 'end')
        if (us_input in cur_values):
            self.currency = us_input
            coins = self.key.get_balance(self.currency)
            self.coinLabel.config(text = "Coins: " + coins + " " + self.currency)
    
    def asynconselect(self,evt):
        x = threading.Thread(target = self.onselect, args = (evt,))
        x.start()
    
    def onselect(self, evt):
        # Note here that Tkinter passes an event object to onselect()
        w = evt.widget
        index = 0
        try:
            index = int(w.curselection()[0])
        except IndexError:
            print('Unselected item in list of transactions')
            return
        value = w.get(index)
        cb.copy(value)
        print('You selected item %d: "%s"' % (index, value))
        try:
            response = requests.get(self.trans_url + value)
            print(response.json())
            json_resp = response.json()
            in_address = json_resp['vin'][0]['prevout']['scriptpubkey_address']
            out_address = json_resp['vout'][0]['scriptpubkey_address']
            fee = json_resp['fee']
            money = json_resp['vout'][0]['value']
            block_time = json_resp['status']['block_time']
            block_time = datetime.datetime.fromtimestamp(block_time).strftime('%Y-%m-%d %H:%M:%S')
            self.transactionsVar.set("Transaction: " + str(value) +
                            "\nFrom: " + str(in_address) + 
                            "\nTo: " + str(out_address) +
                            "\nValue: " + str(money) + " satoshi" +
                            "\nFee: " + str(fee) + " satoshi" + 
                            "\nTime: " + block_time)
        except BaseException:
            messagebox.showerror(title = 'Error', message = 'Maybe problems with connection or you don\'t have transactions')
    
    def asyncSendCoins(self):
        x = threading.Thread(target = self.sendCoins)
        x.start()
    
    def sendCoins(self):
        us_address = self.sendAddressInput.get()
        us_coins = self.sendCoinsInput.get()
        self.sendAddressInput.delete(0, 'end')
        self.sendCoinsInput.delete(0, 'end')
        try:
            if (us_address == '' or us_coins == ''):
                return
            us_coins = float(us_coins)
        except ValueError:
            print('invalid transformation')
            return
        
        try:
            # Send coins and update labels
            outputs = [
                (us_address, us_coins, self.currency)
            ]
            print(self.key.send(outputs))
            self.updateInterface()
            messagebox.showinfo(title = 'Transacation', message = 'Successed')
        except BaseException:
            messagebox.showerror(title = 'Error', message = 'Maybe, you don\'t have internet connection or use wrong key or you don\'t have enough money')
            
    def asyncUpdateInterface(self):
        x = threading.Thread(target = self.cycleUpdateInterface, daemon = True)
        x.start()
    
    def cycleUpdateInterface(self):
        self.updateInterface()
        self.parent.after(3000, self.asyncUpdateInterface)
            
    def updateInterface(self):
        self.coinLabel.config(text = "Coins: " + self.key.get_balance(self.currency) + " " + self.currency)
        new_transactions = self.key.get_transactions()
        trans_values = self.transactions.get(0, 'end')
        for trans in new_transactions:
            if trans not in trans_values:
                self.transactions.insert(0, trans)

    def copyKey(self):
        cb.copy(self.key.to_wif())
Beispiel #8
0
 def get_action_key(self):
     key = Key()
     data = {"address": key.address, "private_key": key.to_wif()}
     return self._response(data=data)
Beispiel #9
0
#!/usr/bin/env python3

import sys
from bit import Key

vanity = sys.argv[1]

match_found = False
while not match_found:
    key = Key()
    if key.address.startswith("1" + vanity):
        print("Matching found!!!")
        print("Private Key:", key.to_wif())
        print("Address:", key.address)
        match_found = True