I would like to get some feedback. I am new to the bitcoin development and I don't want to misunderstand something important before I start designing the application. I am working on bitcoin online-store integration. We are planning to show btc payment instructions to customers after order acknowledgment page so that they can send the payment from their private wallets.

We want to create one address per transaction. (take Transaction No = "abc"). My plan:

  • First call getaddressesbyaccount("abc"). If it returns blank address list, then call getnewaddress("abc") to create new address for this order. (Then create QR code and show to customer with expected amount).
  • Otherwise, if the getaddressesbyaccount("abc") returns an address, use that returning address.

This page says "getaccountaddress will return the same address until coins are received on that address; once coins have been received, it will generate and return a new address.".

I am planning not to use this function because if we expect 1 btc from the customer and he sends 0.5 btc, I don't want to create a new address. This is just to keep things simplified (1 address per 1 account). getaddressesbyaccount function returns a list of addressess associated with the account "abc". I find getaccountaddress redundant for my needs. Is there any benefit to "getaccountaddress" creating new address if the current address has balance on it? Do you see any pitfall with my logic. Your feedback is appreciated.

Thank you,

2 Answers 2


I recommend that you do not use Bitcoin Core's internal accounting system because it is deprecated and will be removed in the future. Once it is removed, whatever code you have written that depends on it will be broken. Furthermore, the accounts system is not all that good.

I suggest that you instead maintain a separate database where you keep your own accounting system. That database would record each user's address and how much has been paid to that address. To figure out how much has been paid to each address, you would have a script that is called by -walletnotify which then looks up what address is being paid and how much for each transaction that you receive.

There are software that handle this sort of payment processing for you already that can be used with Bitcoin Core. One such software is BTCPay.

  • For some business reasons, we need to develop this internally. So BTCPay isn't an option. Our plan is to use an external database and a controller to send commands to Bitcoin Core service for address creation and querying. A service similar to -walletnotify is also within the scope. Commented Feb 12, 2018 at 14:59
  • @SerdarUlutas one additional comment i have for -walletnotify is that it sends out two notifications on incoming tx. one when it's added to mempool (confirmation=0) and one when it's first added to a block (confirmation=1). you'd probably need additional steps to make sure it reach certain number of confirmations before calling it final
    – Will Gu
    Commented Apr 16, 2018 at 6:38

My suggestion is to fire it up on -testnet and see what it does. You can get some testnet BTC from a faucet for testing.

Also, you probably realise you can get information on the various commands from help:

>bitcoin-cli help getaccountaddress

getaccountaddress "account"

DEPRECATED. Returns the current Bitcoin address for receiving payments to this account.

1. "account"       (string, required) The account name for the address. It can also be set to the empty string "" to represent the default account. The account does not need to exist, it will be created and a new address created  if there is no account by the given name.

"address"          (string) The account bitcoin address

> bitcoin-cli getaccountaddress 
> bitcoin-cli getaccountaddress ""
> bitcoin-cli getaccountaddress "myaccount"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaccountaddress", "params": ["myaccount"] }' -H 'content-type: text/plain;'

There is no mention of a new address being created once BTC is received on a particular address.

Also, many of the commands that you are discussing are depreciated - there are probably new methods available. >bitcoin-cli help will list all available commands.

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.