Bring back getHeight()
please bring back the getHeight() method which returns block height. it was there in 0.31.1
Are you looking for this in one of the 1.0 alphas?
yes. can't seem to find it there
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: https://github.com/bitcoindevkit/BDKSwiftExampleWallet/commit/d275596fb4dfa139626ee0271928976866e1815c#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!).
@geigerzaehler242 does that resolve your issue/question or any other thoughts or follow up?
the method previously returned the current block height of the time chain. i guess it was just doing an api call to mempoolspace?
https://docs.rs/bdk/0.29.0/bdk/blockchain/trait.GetHeight.html#tymethod.get_height
Adding a link to pre-1.0 docs method
The current 1.0 beta doesnt have get_height anywhere. Can this please be included again?
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 : Thanks. @thunderbiscuit, @reez : Can this also be added for electrum client?
@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-
@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 : 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-
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
@reez : Ok. I hoped there would be a bdk-native way. But thanks.