I need to add Bitcoin payment to my application using the BitcoinJ library, but I'm new to using Bitcoin. I have one thought To create a new address for each new user, but I don't know if this is the right approach or not. Please tell me how to implement it correctly.

(I need to determine from which user the payment was received and in what amount)

1 Answer 1


Not really for BitcoinJ, but a general approach.

You generate new address for every user you register. Store it in your DB with the userID for future reference.

Create a getAPI taking a String input. use your API endpoint and open the Bitcoin.conf file.

walletnotify=curl <your API>

If you want to have confirmation logic as well, you may need one more getAPI, and get the endpoint. then update your bitcoin.conf file again with following:

blocknotify=curl <your Block API> 

Now when user makes the deposit to the address you generated, Bitcoin node will notify your app by calling the wallet notify API. You get the transaction hash. Use that txHash and make a Post call to your daemon with RPc command:

getTransaction <txHash>

Now you'll have entire transaction object to find which user has made the deposit.

Free tip: Bitcoin node calls walletnotify two times:

  1. When a transaction is added to the chain.
  2. When that transaction receives first confirmation.

If you don't want more than one confirmation, then blockNotify is not needed.

If you want a practical example, you can check my Github repo, where I have done it. It's not based on BitcoinJ but the logic remains the same:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.