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

Bring back getHeight() #547

Closed
geigerzaehler242 opened this issue May 30, 2024 · 14 comments · Fixed by #623
Closed

Bring back getHeight() #547

geigerzaehler242 opened this issue May 30, 2024 · 14 comments · Fixed by #623
Labels
enhancement New feature or request

Comments

@geigerzaehler242
Copy link

please bring back the getHeight() method which returns block height. it was there in 0.31.1

@geigerzaehler242 geigerzaehler242 added the enhancement New feature or request label May 30, 2024
@reez
Copy link
Collaborator

reez commented May 30, 2024

Are you looking for this in one of the 1.0 alphas?

@geigerzaehler242
Copy link
Author

yes. can't seem to find it there

@reez
Copy link
Collaborator

reez commented May 30, 2024

Yeah, it’s there but just in a different place/way because 1.0 is structured a bit differently, so I can totally understand it being hard to find at the moment.

We do have it though, here is one spot I’m using it in BDKSwiftExampleWallet as of recently when I updated main to 1.0 alpha 11: bitcoindevkit/BDKSwiftExampleWallet@d275596#diff-846bbaac2100f437c6f4c82df4cfcb50de5aba72dd8d0252731e44f0112db272R48-R55

That’s essentially my Transaction Detail View where I’m showing a transaction and what block height it was confirmed (or if it’s unconfirmed), etc.

Let me know if that’s the sort of thing you’re looking for or not, or any other thoughts/questions around it, since I definitely know things are structured differently in 1.0 and it might take a bit to get the hang of things (its really nice though!).

@reez
Copy link
Collaborator

reez commented Jun 11, 2024

@geigerzaehler242 does that resolve your issue/question or any other thoughts or follow up?

@geigerzaehler242
Copy link
Author

the method previously returned the current block height of the time chain. i guess it was just doing an api call to mempoolspace?

@reez
Copy link
Collaborator

reez commented Jun 17, 2024

@andreasgriffin
Copy link
Contributor

The current 1.0 beta doesnt have get_height anywhere. Can this please be included again?

@reez
Copy link
Collaborator

reez commented Nov 5, 2024

This is the method to expose I think:

    /// Get the height of the current blockchain tip.
    pub fn get_height(&self) -> Result<u32, Error> {
        self.get_response_str("/blocks/tip/height")
            .map(|s| u32::from_str(s.as_str()).map_err(Error::Parsing))?
    }

@reez reez linked a pull request Nov 6, 2024 that will close this issue
8 tasks
@andreasgriffin
Copy link
Contributor

@reez : Thanks. @thunderbiscuit, @reez : Can this also be added for electrum client?

@reez
Copy link
Collaborator

reez commented Nov 8, 2024

@reez : Thanks. @thunderbiscuit, @reez : Can this also be added for electrum client?

@andreasgriffin

Would be happy to! Do you know exactly what method you'd want for it because when I was looking thru the available methods I wasn't seeing something close enough to the get_height that is found on Esplora? Sorry if I'm missing it and its obvious, maybe I'm not quite as familiar w Electrum as I am with Esplora-

@andreasgriffin
Copy link
Contributor

@reez : The get_height was (before 1.0) in the electrum client: https://github.com/bitcoindevkit/bdk/blob/213c270ab475e2afbf6863271550a537cd203c15/src/blockchain/electrum.rs#L94

Is it possible to bring it back?

@reez
Copy link
Collaborator

reez commented Nov 8, 2024

@reez : The get_height was (before 1.0) in the electrum client: https://github.com/bitcoindevkit/bdk/blob/213c270ab475e2afbf6863271550a537cd203c15/src/blockchain/electrum.rs#L94

Is it possible to bring it back?

Let me ask in our Discord channel right now to try to fill in some of the details for myself-

@reez
Copy link
Collaborator

reez commented Nov 12, 2024

Per Evan:

You can subscribe to block header notifications.

I think it's the only way unfortunately

https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-methods.html#blockchain-headers-subscribe

The subscribe request returns height + blockhash directly

@andreasgriffin
Copy link
Contributor

@reez : Ok. I hoped there would be a bdk-native way. But thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants