Bitcoin Forum
December 04, 2016, 04:29:26 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Creating a huge batch file of receiving addresses?  (Read 997 times)
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 08, 2011, 02:50:23 PM
 #1

I'm working on a widget to accept donations autonomously at http://www.bitcoin-charity.com/ but want to avoid having to run a bitcoin client on a server for it to work. I'm trying to figure out how I could simply make a few thousand random receiving addresses and dump them into a SQL table. Anyone got advice?
1480868966
Hero Member
*
Offline Offline

Posts: 1480868966

View Profile Personal Message (Offline)

Ignore
1480868966
Reply with quote  #2

1480868966
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 08, 2011, 03:46:32 PM
 #2

Still trying to figure this out - I thought it was a routine thing?
Meni Rosenfeld
Donator
Legendary
*
Offline Offline

Activity: 1890



View Profile WWW
July 08, 2011, 03:57:55 PM
 #3

I don't think it's possible with the GUI. But it should be doable with the API (see this for example. Call getnewaddress in a loop and dump the returned values to a file). I don't know much about this myself though.

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 08, 2011, 04:06:46 PM
 #4

I don't think it's possible with the GUI. But it should be doable with the API (see this for example. Call getnewaddress in a loop and dump the returned values to a file). I don't know much about this myself though.

Sounds like that would work, but I guess I need to start getting familiar with the API. If anyone has the know-how and wants to whip this up for me feel free  Smiley Probably a simple task once you get to know the coding.
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 09, 2011, 12:19:27 AM
 #5

Bump - anyone else got advice?
casascius
Mike Caldwell
VIP
Legendary
*
Offline Offline

Activity: 1344


The Casascius 1oz 10BTC Silver Round (w/ Gold B)


View Profile WWW
July 09, 2011, 12:31:37 AM
 #6

What language are you coding in?  You could code the site to generate brand new addresses and save the private key for later import.

Companies claiming they got hacked and lost your coins sounds like fraud so perfect it could be called fashionable.  I never believe them.  If I ever experience the misfortune of a real intrusion, I declare I have been honest about the way I have managed the keys in Casascius Coins.  I maintain no ability to recover or reproduce the keys, not even under limitless duress or total intrusion.  Remember that trusting strangers with your coins without any recourse is, as a matter of principle, not a best practice.  Don't keep coins online. Use paper wallets instead.
J.P. Larocque
Newbie
*
Offline Offline

Activity: 29


View Profile
July 09, 2011, 04:42:29 AM
 #7

Still trying to figure this out - I thought it was a routine thing?

I imagine most people doing this run a Bitcoin daemon on their server.  But there's nothing wrong with your approach, just make sure to do something sensible when you run out of addresses!

Do you have Python available?  Here's a script (that's not as simple as it could be): call it with the number of addresses you'd like to create, and it will print out each address.  So redirect the output to a file by putting "> addresses.txt" after the call to the script on the command line.

Code:
#!/usr/bin/env python

# 2011-07-08 J.P. Larocque.  Public domain.

RPC_URL = "http://127.0.0.1:8332/"
#RPC_PASSWORD = "topseekrit"
RPC_PASSWORD = None # Prompts if None.

import os, sys, json, random, getpass, base64, urllib2

def print_usage ():
    print >>sys.stderr, ("Usage: %s NUM_ADDRS [ACCOUNT]" %
                         (os.path.basename (sys.argv[0]),))

def main (args):
    if not (1 <= len (args) <= 2):
        print_usage ()
        return 2
    try:
        num_addrs = int (args[0])
        if num_addrs < 0:
            raise ValueError, "NUM_ADDRS must be a non-negative integer."
        account = None if len (args) == 1 else args[1]
    except ValueError, e:
        print >>sys.stderr, e
        print_usage ()
        return 2
    for i in xrange (num_addrs):
        print getnewaddress (account)

def getnewaddress (account):
    return bitcoin (["getnewaddress", "" if account is None else account])

_opener = urllib2.build_opener (urllib2.ProxyHandler ({}))
def bitcoin (args):
    global RPC_PASSWORD
    if RPC_PASSWORD is None:
        RPC_PASSWORD = getpass.getpass ("RPC password: ")
    return trivial_jsonrpc (RPC_URL, "", RPC_PASSWORD, _opener,
                            args[0], args[1:])

def trivial_jsonrpc (url, username, password, opener, method, params):
    # Disclaimer: I don't know JSON-RPC, and I don't care to.
    req = {"jsonrpc": "1.0",
           "id": "%16X" % (random.randrange (2**64),),
           "method": method,
           "params": params}
    urllib2_req = urllib2.Request (url, json.dumps (req))
    urllib2_req.add_header ("Content-Type", "application/json")
    urllib2_req.add_header ("Authorization",
                            "Basic " + base64.encodestring (username + ":" + password).replace ("\n", ""))
    urllib2_resp = opener.open (urllib2_req)
    resp = json.load (urllib2_resp)
    assert req["id"] == resp["id"]
    if resp["error"] is not None:
        raise ValueError, resp["error"]
    return resp["result"]

if __name__ == "__main__":
    sys.exit (main (sys.argv[1:]))

To use this, you'll need to make sure that your copy of Bitcoin is listening for RPC connections.  You can do this by editing a text file called "bitcoin.conf" (create it if it doesn't exist) in your Bitcoin data directory and add this:

Code:
rpcpassword=SECRET

Substituting a new, real password for SECRET.  Restart Bitcoin for the change to take effect.

You can run the above Python script by saving it to a text file and running this from your command line:

Code:
python bitcoin-getnewaddresses.py 1000 > addresses.txt
RPC password: [not echoed]

If this works for you, feel free to send what you think this was worth my way: 1FMC9HqiEP6Xuk4WJhEZEYK36CqovxeVQy
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 09, 2011, 01:03:02 PM
 #8

Great, thank you, I'll give it a try. I unfortunately don't personally own any bitcoins, just what my charity has received and I can't use it for stuff like this. If I ever get any I'll send some your way.
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 09, 2011, 01:16:54 PM
 #9

What language are you coding in?  You could code the site to generate brand new addresses and save the private key for later import.

I use PHP for the site but I can pick up anything pretty quick. The goal is to keep the website out of the equation as much as possible if there's a simple way to prevent it. No point in creating possible security holes!
bitlotto
Hero Member
*****
Offline Offline

Activity: 672


BitLotto - best odds + best payouts + cheat-proof


View Profile WWW
July 09, 2011, 01:44:18 PM
 #10

If you wanted to create addresses you could also mix up the code at:
https://forum.bitcoin.org/index.php?topic=23081.0
It's pretty much a script that will make bitcoin addresses along with a private key.
If you alter the shell script into a loop and take out the other stuff you could create a lot of addresses that get put into a file. The only hard part would be importing them back into Bitcoin though.

*Next Draw Feb 1*  BitLotto: monthly raffle (0.25 BTC per ticket) Completely transparent and impossible to manipulate who wins. TOR
TOR2WEB
Donations to: 1JQdiQsjhV2uJ4Y8HFtdqteJsZhv835a8J are appreciated.
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 09, 2011, 02:04:41 PM
 #11

Gave your script a try, jp_larocque. Not sure what's going wrong:



I'm thinking maybe my bitcoin.conf isn't setup correctly?

edit: I was right, but I got a new error message: Errno 10054: An existing connection was forcibly closed by the remote host.

edit3: wooo! figured it out, tried a different port and it worked. Thanks a ton!
hayden
Jr. Member
*
Offline Offline

Activity: 34


View Profile
July 09, 2011, 02:07:03 PM
 #12

If you wanted to create addresses you could also mix up the code at:
https://forum.bitcoin.org/index.php?topic=23081.0
It's pretty much a script that will make bitcoin addresses along with a private key.
If you alter the shell script into a loop and take out the other stuff you could create a lot of addresses that get put into a file. The only hard part would be importing them back into Bitcoin though.

I'm afraid at this point this is a little over my head - I don't understand at all what's going on there.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!