Closed stgleb closed 6 years ago
@stgleb This might be related to something I had. I was using the gRPC interface and using the methods getnewaddress(account=0)
gave me an address that, when funded and confirmed, did not show up in getbalances(account=0)
.
I already suspected there must have been a confusion between addresses somehow.
I never worked on the btcwallet codebase, so I have no idea. Just reporting a similar experience.
Bitcoin addresses do not have balances, they can only receive payments. I'm sorry but you're looking for a feature that doesn't exist by design.
See https://en.bitcoin.it/wiki/From_address for more details
@jrick Ok, but why public explorers provide balance functionality? https://blockchain.info/charts/balance?address=1M3GipkG2YyHPDMPewqTpup83jitXvBg9N
They are lying to you
@jrick thats bad, in such case how can I get balance for accout? How I specify this account in btcwallet?
btcctl --wallet getbalance <account name>
@jrick Don't be so hard :p
Even though it doesn't actually exist explicitly, there does exist a notion of an address balance, being the sum of all the unspent outputs spendable with the private key that converts to given address. I realize it's not easy to expose though and should probably not be exposed to avoid user confusion.
@jrick Thanks, but what account name is actually is? Is it a publick key or what? I may ask stupind questions, but I've realized that README doesn't have simple instructions for this case.
I think the default account is "0". Wait until @jrick confirms though.
On 15 Mar 2018 5:04 pm, "Gleb" notifications@github.com wrote:
@jrick https://github.com/jrick Thanks, but what account name is actually is? Is it a publick key or what? I may ask stupind questions, but I've realized that README doesn't have simple instructions for this case.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/btcsuite/btcwallet/issues/497#issuecomment-373429916, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0F3Fg2gPKRynt0CZ-IWtqBX2OvSNX7ks5tepEWgaJpZM4SrB_G .
it's called "default", but the account number of the default account is 0.
Yes, but if I have public&private keys that forms an account. How I can stick this account to btcwallet?
@stgleb You don't. btcwallet works with accounts, which represent a collection of keys and addresses. You should not know any of the public or private keys when using btcwallet and should treat all addresses it gives you as one-time-use.
All you need to know is your account, which by default is default
or 0.
@stevenroose But what If I need access to balance of existing account that already has funds?
@stgleb You should give more information about what you're trying to do.
If you have an address from some other service that is not btcwallet, you cannot get the balance for that address.
(If you have a working btcd node (with address index), you could use the (experimental) gRPC server to get all unspent outputs for the address and add all the output values. Use GetAddressUnspentOutputs.)
@stevenroose Ok, I have working btcd node. I want to get a balance of specific address. I need to create an wallet and somehow get an address of that account.
@stgleb Again, in btcwallet, you can create an account and get addresses for that account. But you can only get the total balance of the account, not the individual balances of the addresses.
Have you considered using some of the public block explorers?
@stevenroose So, I can create an account, but I cant get neither private nor public key from the wallet? I already use public explorers, but to be sure I would like to use my own btcd node installation for controlling that.
You shouldn't really have to do that, no. There is dumpprivkey
that you could use to dump private keys, I guess.
I have started btcwallet server and connect it to working btcd node using tls
/btcwallet --rpcconnect=<host>:<port> --btcdusername=<btcdUsername> --btcdpassword=<btcdPassword> -u <user> -P <password>
btcwallet connects to btcd node and I try to get balance of address.
But I receive
address not found in wallet
error that comes fromhttps://github.com/btcsuite/btcwallet/blob/master/waddrmgr/db.go#L1167
What I do wrong with setting up btc wallet? Maybe I should register address or account somehow?