Accept payments on someone else's behalf without being able to spend them TL;DR I wish to store some sort of key in my application for each vendor account that allows for my application to generate a receiving address for clients to make payments to.

I am writing some invoice software in Java that I would like to allow to use bitcoin. Basically what I want to have happen is a vendor can save some sort of key to their account details (sorta like the PayPal id and secret key) and any clients paying to that vendor via bitcoin will be given the url to pay to. I don't want this to be a middle man software in the sense that I will never have any bitcoins on my server, I won't accept payments, it only serves to give a payment address of the vendor to a client.

I am under the understanding that this would be possible using the receiving address, however it is not good to use one address for every payment so that is out of the question. I don't want a vendor to have to add a new address after every payment because that isn't at all user friendly.

So I'm wondering if there's some way I can generate addresses for the vendor on my server without holding their wallet. I have been looking at bitcoinj and it seems like there may be some way to do it, but I am quite new to bitcoin. Is that even a possibility? Is this a reasonable expectation for my application to have? If not, do I have any other options?
This is entirely possible with an optional additon to Bitcoin called BIP32. Unfortunately, BIP32 is not implemented by the standard client, but there are other clients that do implement it.


Ask your customer to download the latest version of Electrum, then have them give you their extended public key.

(As I said above, there are multiple clients that can do this, I'm just most familiar with Electrum.)
Include this code in your BitcoinJ application:

String serialized_xpub = "xpub.....";
unsigned int address_num = 4;
NetworkParameters params = MainNetParams.get();
DeterministicKey root_xpub = DeterministicKey.deserializeB58(null, serialized_xpub, params);

// Derive m/0/&lt;n&gt;, Electrum's BIP32 path
DeterministicKey receiving = HDKeyDerivation.deriveChildKey(root_xpub, new ChildNumber(0, false));
DeterministicKey new_address_key = HDKeyDerivation.deriveChildKey(receiving, new ChildNumber(address_num, false));
String new_address = new_address_key.toAddress().toString();


You will generate the same address as long as you use the same xpub and address_num. Make sure that you don't skip five or more addresses, though. If you do end up doing this, then your customer can generate addresses until they see the new payments.

Also, note that you don't have the private key for this address. If your customer loses their wallet, those coins are gone.
Put that address on the invoice.
The money will show up in their wallet. 


Best of luck with your application!