Skip to content
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 the visibility of the derived module and of the AsDerived trait #520

Closed

Conversation

w0xlt
Copy link
Contributor

@w0xlt w0xlt commented Jan 9, 2022

There is currently no way to retrieve change addresses, so this PR changes the visibility of the derived module and the AsDerived trait.

With this change, the addresses can be retrieved using the function below, for example:

use bdk::descriptor::derived::AsDerived;

// ...

fn peek_change_address(&self, wallet: &Wallet<ElectrumBlockchain, MemoryDatabase>, index: u32) -> Result<AddressInfo, Error> {

        let result_descriptor = wallet.get_descriptor_for_keychain(bdk::KeychainKind::Internal);

        result_descriptor
            .as_derived(index, wallet.secp_ctx())
            .address(wallet.network())
            .map(|address| AddressInfo { index, address })
            .map_err(|_| Error::ScriptDoesntHaveAddressForm)
    }

Currently this module is visible only in the crate, so it
can't be accessed externally.
@LLFourn
Copy link
Contributor

LLFourn commented Jan 10, 2022

I happened to need this feature for gun. Here's the (slightly messy) commit that adds the feature: LLFourn@e0950b9

I think this is a better way to do this. I'll see if I can clean up this commit and upstream it.

@LLFourn
Copy link
Contributor

LLFourn commented Jan 11, 2022

Here I've made a PR that allows you to do this: #522

@rajarshimaitra
Copy link
Contributor

rajarshimaitra commented Jan 11, 2022

ACK, #522 is much cleaner way to do it.

@w0xlt
Copy link
Contributor Author

w0xlt commented Jan 11, 2022

Agree.
#522 is a better approach to achieve this change.
I will close this PR.

@w0xlt w0xlt closed this Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants