<p>The long and short of it is that you can't associate UTXOs with accounts, you can only associate addresses. From the <a href="https://en.bitcoin.it/wiki/Accounts_explained" rel="nofollow noreferrer">bitcoin wiki accounts page</a>:</p>

<blockquote>
  <p>When you receive bitcoins, they are always assigned to one of your accounts, and you can change which account is credited based on which bitcoin address receives the coins, just like you tell a bank teller which account to credit when you deposit cash in your bank. However, sending bitcoins is like withdrawing cash from the bank; the coins that are sent out and debited from an account are almost always not the same coins that were deposited into that account.</p>
</blockquote>

<p>If you haven't already, you should see <a href="https://bitcoin.stackexchange.com/questions/21153/bitcoin-accounts-feature-is-it-practical-or-scalable">this post</a> about why the accounts portion of the tab isn't really scalable. </p>

<blockquote>
  <p>I thought I'd be able to use getaccount with the returned corresponding addresses, but I'm returned an empty string. Is that because the transaction originated from the wallet 'global' account?</p>
</blockquote>

<p>Yes, that is exactly, why. The default account is named "". </p>

<p>So, you can associate UTXOs with accounts through associating addresses with accounts, but when spending, there's no guarantee about where you're spending from.</p>

<p>As a possible work around, you might look at using this rpc call:</p>

<pre><code>listreceivedbyaddress ( minconf includeempty )
</code></pre>

CC BY-SA 3.0
2014-10-26T22:19:01.593Z
thanks! really useful! so how does `sendfrom` choose its utxo's to ensure spending from the right account? i see from your links that performance would likely wain the more and more accounts you have, but could you predict the utxo's the wallet will choose for a `sendfrom` knowing that it will always attempt to pull from the default account? i've seen other posts mentioning the routine but not in regards to accounts
Jon B
CC BY-SA 3.0
2014-10-27T02:57:03.177Z
I'm not exactly sure how it prioritizes them, I've asked that question [here](http://bitcoin.stackexchange.com/questions/32145/how-does-the-core-client-decide-which-utxos-to-spend). As a side note, if you need to tell it exactly which UTXOs to spend, you can do that with `createrawtransaction` and `signrawtransaction`.
morsecoder
CC BY-SA 3.0
2014-10-26T11:09:53.820Z
2014-10-26T11:09:53.820Z
2017-04-13T12:47:34.187Z
morsecoder
<p>I'm building a web application that uses bitcoind's accounts to track user balances. My dev env is currently in <code>regtest</code> mode. I am working on calculating the network transaction fee prior to creating a raw transaction. </p>

<p>When I <code>listunspent</code> to bitcoind over JSON-RPC, I get a multidim array that includes txid, address, and scriptPubKey (amongst other things). How can I use this information to determine which account these utxo's are tied to? I thought I'd be able to use <code>getaccount</code> with the returned corresponding addresses, but I'm returned an empty string. Is that because the transaction originated from the wallet 'global' account? Is that something to do with regression testing mode?</p>

<p>I also tried <code>listtransactions</code> for the specific account to match txid, but didn't have txid's because they were moves. Even if I could do this for network transactions, how would I handle utxo's that were resulting from a move?</p>

<p>I can <code>getbalance</code> for different accounts and see the correct resulting balances from using the <code>move</code> command. I'm beginning to question a few things so I'm not sure where I have an problem or if I'm going about this the wrong way. Ultimately, my goal is to be able to calculate tx fee so the user can approve them before sending...keeping in mind single wallet with each user having their own account.</p>

<p>Thanks for the help! ...it's late and my head hurts lol</p>

<bitcoind><transaction-fees><json-rpc><raw-transaction><utxo>
What is the easiest way to associate an utxo to a specific account?
Jon B
# What is the easiest way to associate an utxo to a specific account?

(Asked by: username_0 on 2014-10-26)

I'm building a web application that uses bitcoind's accounts to track user balances. My dev env is currently in `regtest` mode. I am working on calculating the network transaction fee prior to creating a raw transaction.

When I `listunspent` to bitcoind over JSON-RPC, I get a multidim array that includes txid, address, and scriptPubKey (amongst other things). How can I use this information to determine which account these utxo's are tied to? I thought I'd be able to use `getaccount` with the returned corresponding addresses, but I'm returned an empty string. Is that because the transaction originated from the wallet 'global' account? Is that something to do with regression testing mode?

I also tried `listtransactions` for the specific account to match txid, but didn't have txid's because they were moves. Even if I could do this for network transactions, how would I handle utxo's that were resulting from a move?

I can `getbalance` for different accounts and see the correct resulting balances from using the `move` command. I'm beginning to question a few things so I'm not sure where I have an problem or if I'm going about this the wrong way. Ultimately, my goal is to be able to calculate tx fee so the user can approve them before sending...keeping in mind single wallet with each user having their own account.

Thanks for the help! ...it's late and my head hurts lol

**Tags:** bitcoind, transaction-fees, json-rpc, raw-transaction, utxo


---

## 1 answers

### Answer by username_1 on 2014-10-26. Score: 1 | Accepted answer

The long and short of it is that you can't associate UTXOs with accounts, you can only associate addresses. From the [bitcoin wiki accounts page](https://en.bitcoin.it/wiki/Accounts_explained):

> When you receive bitcoins, they are always assigned to one of your accounts, and you can change which account is credited based on which bitcoin address receives the coins, just like you tell a bank teller which account to credit when you deposit cash in your bank. However, sending bitcoins is like withdrawing cash from the bank; the coins that are sent out and debited from an account are almost always not the same coins that were deposited into that account.

If you haven't already, you should see [this post](https://bitcoin.stackexchange.com/questions/21153/bitcoin-accounts-feature-is-it-practical-or-scalable) about why the accounts portion of the tab isn't really scalable.

> I thought I'd be able to use getaccount with the returned corresponding addresses, but I'm returned an empty string. Is that because the transaction originated from the wallet 'global' account?

Yes, that is exactly, why. The default account is named "".

So, you can associate UTXOs with accounts through associating addresses with accounts, but when spending, there's no guarantee about where you're spending from.

As a possible work around, you might look at using this rpc call:

```
listreceivedbyaddress ( minconf includeempty )

```

> **Comments:**
> **username_0**: thanks! really useful! so how does `sendfrom` choose its utxo's to ensure spending from the right account? i see from your links that performance would likely wain the more and more accounts you have, but could you predict the utxo's the wallet will choose for a `sendfrom` knowing that it will always attempt to pull from the default account? i've seen other posts mentioning the routine but not in regards to accounts  
> **username_1**: I'm not exactly sure how it prioritizes them, I've asked that question [here](http://bitcoin.stackexchange.com/questions/32145/how-does-the-core-client-decide-which-utxos-to-spend). As a side note, if you need to tell it exactly which UTXOs to spend, you can do that with `createrawtransaction` and `signrawtransaction`.  

---

