<p>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.</p>

<p>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 <code>-walletnotify</code> which then looks up what address is being paid and how much for each transaction that you receive.</p>

<hr>

<p>There are software that handle this sort of payment processing for you already that can be used with Bitcoin Core. One such software is <a href="https://github.com/btcpayserver/btcpayserver" rel="nofollow noreferrer">BTCPay</a>.</p>

CC BY-SA 3.0
2018-02-12T14:59:17.030Z
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.
Serdar Ulutas
CC BY-SA 3.0
2018-04-16T06:38:16.163Z
@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
CC BY-SA 3.0
2018-02-11T07:19:58.223Z
2018-02-11T07:19:58.223Z
Ava Chow
<p>My suggestion is to fire it up on <code>-testnet</code> and see what it does. You can get some testnet BTC from a faucet for testing.</p>

<p>Also, you probably realise you can get information on the various commands from help:</p>

<p><code>&gt;bitcoin-cli help getaccountaddress</code></p>

<pre><code>getaccountaddress "account"

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

Arguments:
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.

Result:
"address"          (string) The account bitcoin address

Examples:
&gt; bitcoin-cli getaccountaddress 
&gt; bitcoin-cli getaccountaddress ""
&gt; bitcoin-cli getaccountaddress "myaccount"
&gt; curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaccountaddress", "params": ["myaccount"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
</code></pre>

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

<p>Also, many of the commands that you are discussing are depreciated - there are probably new methods available. <code>&gt;bitcoin-cli help</code> will list all available commands.</p>

CC BY-SA 3.0
2018-02-11T00:45:53.087Z
2018-02-11T00:45:53.087Z
Willtech
<p>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. </p>

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

<ul>
<li>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). </li>
<li>Otherwise, if the getaddressesbyaccount("abc") returns an address,
use that returning address.</li>
</ul>

<p><a href="https://en.bitcoin.it/wiki/Help:Accounts_explained#Accounts_and_Receiving_Addresses" rel="nofollow noreferrer">This page</a> says <em>"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.</em>". </p>

<p>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. </p>

<p>Thank you,</p>

<bitcoind><bitcoin-core-development><bitcoin-cli>
Question on getaccountaddress, getnewaddress, getAddressesByAccount
Serdar Ulutas
# Question on getaccountaddress, getnewaddress, getAddressesByAccount

(Asked by: username_0 on 2018-02-10)

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](https://en.bitcoin.it/wiki/Help:Accounts_explained#Accounts_and_Receiving_Addresses) says *"getaccountaddress username_2 return the same address until coins are received on that address; once coins have been received, it username_2 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,

**Tags:** bitcoind, bitcoin-core-development, bitcoin-cli


---

## 2 answers

### Answer by username_1 on 2018-02-11. Score: 3

I recommend that you do not use Bitcoin Core's internal accounting system because it is deprecated and username_2 be removed in the future. Once it is removed, whatever code you have written that depends on it username_2 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](https://github.com/btcpayserver/btcpayserver).

> **Comments:**
> **username_0**: 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.  
> **username_2**: @username_0 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  

---

### Answer by username_3 on 2018-02-11. Score: 0

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.

Arguments:
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 username_2 be created and a new address created  if there is no account by the given name.

Result:
"address"          (string) The account bitcoin address

Examples:
> 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;' http://127.0.0.1:8332/

```

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` username_2 list all available commands.


---

