<p>I think it did work, but the <code>getbalance</code> function does not work as you expect. The <code>./bitcoin-cli -regtest help getbalance</code> reveals that <code>getbalance</code> returns</p>

<blockquote>
  <p>"The available balance is what the wallet considers currently
  spendable."</p>
</blockquote>

<p>The address you generated with <code>./bitcoin-cli -regtest getnewaddress</code> is probably just a script that routes the funds back into your main account, so it's address is different, but can be spent using the private key in the main account. You can verify this by <code>./bitcoin-cli -regtest listaccounts</code> and seeing if it returns something like:</p>

<pre><code>{
  "": 10.00000000,
  ...
}
</code></pre>

<p>The <code>""</code> account is the default account, and you can get it's address using: <code>./bitcoin-cli -regtest getaccountaddress ""</code>.</p>

<p>It might be more convenient to generate an address as a new bitcoind wallet account. Try using:</p>

<p><code>./bitcoin-cli -regtest getaccountaddress "&lt;optional_name&gt;"</code></p>

<p>Then send the coins to that address and check it's balance using <code>./bitcoin-cli -regtest listaccounts</code></p>

CC BY-SA 4.0
2018-07-17T03:20:42.703Z
Yes, As you said that I have a account with empty string name. So, How can I set a new account to the default account? Also I want to delete that one without name /
Frank AK
CC BY-SA 4.0
2018-07-16T16:02:12.570Z
2018-07-16T16:02:12.570Z
JBaczuk
<p>It's seems like <a href="https://bitcoin.stackexchange.com/questions/70416/sendtoaddress-not-deducting-from-account">this</a> question, but it's no clear show. I have followed <a href="https://bitcoin.org/en/developer-examples#simple-spending" rel="nofollow noreferrer">this</a> step by step, and after finish last step which generate a block to confirm the transaction, I couldn't see my second address have add money (bitcoin). Anyone who encountered such problem?</p>

<p><strong>My bitcoin.conf</strong></p>

<pre><code>[frank@localhost bin]$ cat ~/.bitcoin/bitcoin.conf 
rpcpassword=this_is_a_password_for_api_call
</code></pre>

<p><strong>Run my bitcoind like</strong></p>

<pre><code>[frank@localhost bin]$ ./bitcoind -regtest -daemon
Bitcoin server starting
</code></pre>

<p><strong>Run my bitcoin-cli as</strong></p>

<pre><code>[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
0.00000000

[frank@localhost bin]$ ./bitcoin-cli -regtest generate 101
[
  "7b611f41281c882c7b786c74e01b70e990c102aefb5fc28ee12c1d5b90156fb3",
  "505699b3bcb9faa394cb3533ed970ca48195643e1a034fc8fe64a34e019e12cd",
  "3845286183586d91f3b6a64aa5fb7f741378747b82ed781bc32e2a9d79ac22af",
  "342c881a888de56524368fc04735edfbb23ab1767717df8f9c68218a57b852ee",
....]
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
50.00000000
</code></pre>

<p>You can see what I've done at above, everything so far so good. When I try to do the following thing, I meet some trouble.</p>

<pre><code>[frank@localhost bin]$ ./bitcoin-cli -regtest getnewaddress
2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV

[frank@localhost bin]$ ./bitcoin-cli -regtest sendtoaddress 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV 10
89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18
</code></pre>

<p>For now, I will list all transactions to you:</p>

<pre><code>[frank@localhost bin]$ ./bitcoin-cli -regtest listunspent 0
[
  {
    "txid": "89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18",
    "vout": 0,
    "address": "2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV",
    "account": "",
    "redeemScript": "0014b24df37ce7d779a84b06b35517fae3c8229daa3c",
    "scriptPubKey": "a914910f020cef414bcafc49ab1236c82be6367045f287",
    "amount": 10.00000000,
    "confirmations": 0,
    "spendable": true,
    "solvable": true,
    "safe": true
  },
  {
    "txid": "89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18",
    "vout": 1,
    "address": "2NDjzxeozTK8uZ567tCBvCY9aqCL5wKL4rs",
    "redeemScript": "00143a1c7678f95db28e17c47ab32e9a7e8be5b5150a",
    "scriptPubKey": "a914e0d3b4074fdb1a3defd5ca0e660d3c656b0b054087",
    "amount": 39.99996240,
    "confirmations": 0,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]
</code></pre>

<p>You can see the transaction's confirmations is 0, it's mean no confirmed. so last step I will generate a block to confirm it. but before confirm I simply check both account's balance.</p>

<pre><code>[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
49.99996240
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV
0.00000000
</code></pre>

<p>And we absolute sure the transaction is submit, so go on.</p>

<pre><code>[frank@localhost bin]$ ./bitcoin-cli -regtest generate 1
[
  "0636e8cba682cc382833923e23028664e49ade44764cdf81b375b59675b84e7e"
]
</code></pre>

<p>Okay, We have generate a new block and it's also successful. How about the balance? let check it.</p>

<pre><code>[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV
0.00000000
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
99.99996240
</code></pre>

<p>Sadly, I got nothing in the dest account, but the origin account has increment the balance .So my question is how it's going ?</p>

CC BY-SA 4.0
2018-07-16T13:23:19.553Z
Check to see if the newly generated address is same as the current address - ./bitcoin-cli -regtest getaccountaddress ""
Abhishek Sinha
<transactions><sendtoaddress>
Why I can't do a transaction by use sendtoaddress?
Frank AK
# Why I can't do a transaction by use sendtoaddress?

(Asked by: username_0 on 2018-07-16)

It's seems like this question, but it's no clear show. I have followed this step by step, and after finish last step which generate a block to confirm the transaction, I couldn't see my second address have add money (bitcoin). Anyone who encountered such problem?
My bitcoin.conf
[frank@localhost bin]$ cat ~/.bitcoin/bitcoin.conf 
rpcpassword=this_is_a_password_for_api_call

Run my bitcoind like
[frank@localhost bin]$ ./bitcoind -regtest -daemon
Bitcoin server starting

Run my bitcoin-cli as
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
0.00000000

[frank@localhost bin]$ ./bitcoin-cli -regtest generate 101
[
  "7b611f41281c882c7b786c74e01b70e990c102aefb5fc28ee12c1d5b90156fb3",
  "505699b3bcb9faa394cb3533ed970ca48195643e1a034fc8fe64a34e019e12cd",
  "3845286183586d91f3b6a64aa5fb7f741378747b82ed781bc32e2a9d79ac22af",
  "342c881a888de56524368fc04735edfbb23ab1767717df8f9c68218a57b852ee",
....]
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
50.00000000

You can see what I've done at above, everything so far so good. When I try to do the following thing, I meet some trouble.
[frank@localhost bin]$ ./bitcoin-cli -regtest getnewaddress
2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV

[frank@localhost bin]$ ./bitcoin-cli -regtest sendtoaddress 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV 10
89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18

For now, I will list all transactions to you:
[frank@localhost bin]$ ./bitcoin-cli -regtest listunspent 0
[
  {
    "txid": "89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18",
    "vout": 0,
    "address": "2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV",
    "account": "",
    "redeemScript": "0014b24df37ce7d779a84b06b35517fae3c8229daa3c",
    "scriptPubKey": "a914910f020cef414bcafc49ab1236c82be6367045f287",
    "amount": 10.00000000,
    "confirmations": 0,
    "spendable": true,
    "solvable": true,
    "safe": true
  },
  {
    "txid": "89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18",
    "vout": 1,
    "address": "2NDjzxeozTK8uZ567tCBvCY9aqCL5wKL4rs",
    "redeemScript": "00143a1c7678f95db28e17c47ab32e9a7e8be5b5150a",
    "scriptPubKey": "a914e0d3b4074fdb1a3defd5ca0e660d3c656b0b054087",
    "amount": 39.99996240,
    "confirmations": 0,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]

You can see the transaction's confirmations is 0, it's mean no confirmed. so last step I will generate a block to confirm it. but before confirm I simply check both account's balance.
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
49.99996240
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV
0.00000000

And we absolute sure the transaction is submit, so go on.
[frank@localhost bin]$ ./bitcoin-cli -regtest generate 1
[
  "0636e8cba682cc382833923e23028664e49ade44764cdf81b375b59675b84e7e"
]

Okay, We have generate a new block and it's also successful. How about the balance? let check it.
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV
0.00000000
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
99.99996240

Sadly, I got nothing in the dest account, but the origin account has increment the balance .So my question is how it's going ?

**Tags:** transactions, sendtoaddress

> **Comments:**
> **username_1**: Check to see if the newly generated address is same as the current address - ./bitcoin-cli -regtest getaccountaddress ""  

---

## 1 answers

### Answer by username_2 on 2018-07-16. Score: 1 | Accepted answer

I think it did work, but the getbalance function does not work as you expect. The ./bitcoin-cli -regtest help getbalance reveals that getbalance returns

"The available balance is what the wallet considers currently
  spendable."

The address you generated with ./bitcoin-cli -regtest getnewaddress is probably just a script that routes the funds back into your main account, so it's address is different, but can be spent using the private key in the main account. You can verify this by ./bitcoin-cli -regtest listaccounts and seeing if it returns something like:
{
  "": 10.00000000,
  ...
}

The "" account is the default account, and you can get it's address using: ./bitcoin-cli -regtest getaccountaddress "".
It might be more convenient to generate an address as a new bitcoind wallet account. Try using:
./bitcoin-cli -regtest getaccountaddress ""
Then send the coins to that address and check it's balance using ./bitcoin-cli -regtest listaccounts

> **Comments:**
> **username_0**: Yes, As you said that I have a account with empty string name. So, How can I set a new account to the default account? Also I want to delete that one without name /  

---

