Author

Topic: Creating a huge batch file of receiving addresses? (Read 1190 times)

member
Activity: 105
Merit: 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.

I'm afraid at this point this is a little over my head - I don't understand at all what's going on there.
member
Activity: 105
Merit: 10
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!
hero member
Activity: 672
Merit: 500
BitLotto - best odds + best payouts + cheat-proof
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.
member
Activity: 105
Merit: 10
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!
member
Activity: 105
Merit: 10
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.
newbie
Activity: 29
Merit: 0
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
vip
Activity: 1386
Merit: 1140
The Casascius 1oz 10BTC Silver Round (w/ Gold B)
What language are you coding in?  You could code the site to generate brand new addresses and save the private key for later import.
member
Activity: 105
Merit: 10
Bump - anyone else got advice?
member
Activity: 105
Merit: 10
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.
donator
Activity: 2058
Merit: 1054
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.
member
Activity: 105
Merit: 10
Still trying to figure this out - I thought it was a routine thing?
member
Activity: 105
Merit: 10
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?
Jump to: