-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change not being detected by wallet #95
Comments
|
We first spotted this bug in stackmate mobile and used bdk-cli to confirm that the error was not in our implementation. Also, stackmate just recently (a week to 10 days ago) updated bdk from 0.13.0 to 0.18.0. We didn't, notice this bug previously OR it might have slipped us since we always just expected get_balance to be displaying the correct result. The first pointer that made us spot something strange was this transaction:
The actual amount we sent was 12k sats. Which we received in the other wallet. But this sending wallet, isn't recognising its change and marking it as a send to external. |
If we look into this tx: |
Just to confirm the above change address is from the same change descriptor:
|
I also noticed that while trying different bdk-cli versions, Will open an other issue for that if I notice it happening more often. So far, this happened twice, with version 0.3.0 and 0.5.0 Edit: Opened issue here |
I have tried to reproduce this problem in regtest.. Apparently the issue is only occurring for this particular descriptor.. I am not being able to generate balance even when I am sending txs..
This creates a watch only wallet named
Now sending transaction to the derived address
The regtest log is only showing outgoing transaction corresponding to the
Get balance from bdk is then showing nothing
And when using
I am not exactly sure what is going on, but this issue seems to be related particularly with that descriptor.. |
really strange... |
I think this is a stop gap address issues, ie. the number of unused addresses looked at during syncing before it stops looking for new transactions. I was able to find all coins by using rm -rf ~/.bdk-bitcoin
bdk-cli wallet -d "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/0/*)" -c "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/1/*)" sync
{}
bdk-cli wallet -d "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/0/*)" -c "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/1/*)" get_balance
{
"satoshi": 1253
}
bdk-cli wallet -d "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/0/*)" -c "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/1/*)" sync --max_addresses 200
{}
bdk-cli wallet -d "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/0/*)" -c "wpkh([8099ce1e/84h/1h/0h]tpubDCBjCC5aZ6wXLtZMSJDkBYZ3AFuors2YzzBhD5ZqP3uPqbzzH5YjD2CA9HDhUYNhrqq67v4XAN93KSbSL4bwa5hEvidkFuj7ycWA7EYzp41/1/*)" get_balance
{
"satoshi": 1156186
} |
This often happens when using a descriptor for testing and generate many new addresses that don't receive any new transactions. |
Cheers @notmandatory! |
This has actually made me aware of another issue that we could potentially bump into on stackmate. We currently allow users to index addresses manually. We didnt initially have this but we added it just for a case with imported wallets. In a case where i have a wallet where the last used index is 6, and i have handed out addresses 7, 8, 9. When i import this wallet, it will start at address 6 and since i know i have used 7, 8, 9 (although not recieved funds) i should be able to increment up to that. I think now, we should limit how many indexes the user can rotate, to prevent them from just incrementing arbitratily and go beyong the index_gap. |
A related PR you might find interesting is: bitcoindevkit/bdk#546 It gives more control to find unused addresses and fill in gaps. Once this is merged and released in BDK it wouldn't be hard to expose this functionality in |
Nice! This is a really useful addition! Thanks! |
Issue
Change from a wallet is not being picked up in
get_balance
when both change and deposit descriptors are used together.When Change descriptor is used alone, funds are detected.
Reproduction Steps
get_balance
Ignoring
sync
The text was updated successfully, but these errors were encountered: