feat: add frigate electrum based RPC methods - #16
Conversation
server.version, blockchain.silentpayments.subscribe and blockchain.silentpayments.unsubscribe225fc0c to
885cd2f
Compare
|
Thanks for the PR! Note that it needs a rebase now with the recent merges. |
… `blockchain.silentpayments.unsubscribe`
oleonardolima
left a comment
There was a problem hiding this comment.
In https://github.com/sparrowwallet/frigate#serverfeatures it mentions the new field in server.features, is it not needed by bdk-sp ?
| /// A request to establish connection with Frigate Electrum client | ||
| /// | ||
| /// This corresponds to the `"server.version"` Frigate Electrum RPC method | ||
| /// | ||
| /// See: https://github.com/sparrowwallet/frigate | ||
| #[cfg(feature = "frigate")] | ||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub struct Version { | ||
| pub client_name: CowStr, | ||
| pub version: CowStr, | ||
| } | ||
|
|
||
| #[cfg(feature = "frigate")] | ||
| impl Request for Version { | ||
| type Response = Vec<String>; | ||
|
|
||
| fn to_method_and_params(&self) -> MethodAndParams { | ||
| ( | ||
| "server.version".into(), | ||
| vec![self.client_name.clone().into(), self.version.clone().into()], | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
The server.version is not an exclusive method of frigate, so I don't think the feature is needed here. Also, if it lands after #11, it'll already be covered.
There was a problem hiding this comment.
Yes indeed, we just need to coordinate which lands first so that I can remove it here.
| pub struct SpSubscribe { | ||
| pub scan_priv_key: bitcoin::secp256k1::SecretKey, | ||
| pub scan_pub_key: bitcoin::secp256k1::PublicKey, | ||
| pub start_height: Option<u32>, |
There was a problem hiding this comment.
In https://github.com/sparrowwallet/frigate#blockchainsilentpaymentssubscribe it also mentions that start_height could be a string in the form FROM-TO, is that format intended to be ignored ?
There was a problem hiding this comment.
It's true it's not mentioned anywhere here but the initial code was for version 1.3.2 (https://github.com/sparrowwallet/frigate/tree/5124333b145acc2a6385f5cd4aeb918c8c896cd7#blockchainsilentpaymentssubscribe)
There has been quite some updates in the meantime. I'm just realising too :)
|
@sdmg15 I just thought this now during the call, but you could also try adding support for these in https://github.com/bitcoindevkit/rust-electrum-client, not sure if the architecture there supports it though. |
| /// Corresponds to `"blockchain.silentpayments.subscribe"` Frigate Electrum notification method | ||
| #[cfg(feature = "frigate")] | ||
| #[derive(Debug, Clone, serde::Deserialize)] | ||
| pub struct SpNotification { |
There was a problem hiding this comment.
I think it's good for consistency to use the same pattern as the other notifications.
pub struct SpNotification {
param_0: SpSubscription,
param_1: f32,
param_2: Vec<TxTweak>,
}
#[cfg(feature = "frigate")]
impl SpNotification {
/// Returns the subscription this notification belongs to.
pub fn subscription(&self) -> &SpSubscription {
&self.param_0
}
/// Returns the scan progress, where `1.0` means up to date.
pub fn progress(&self) -> f32 {
self.param_1
}
/// Returns the transactions discovered by this notification.
pub fn history(&self) -> &[TxTweak] {
&self.param_2
}
}|
|
||
| #[cfg(feature = "frigate")] | ||
| #[derive(Debug, Clone, serde::Deserialize)] | ||
| pub struct SpSubscription { |
There was a problem hiding this comment.
Let's rename it to SpSubscribeResp for consistency and move to src/response.rs
|
|
||
| #[cfg(feature = "frigate")] | ||
| impl Request for SpSubscribe { | ||
| type Response = String; |
There was a problem hiding this comment.
This should be SpSubscription (see here)
This PR adds supports for additional RPC methods provided by Frigate electrum based RPC server.
The added methods are:
server.version: This is the first message sent to establish connection with serverblockchain.silentpayments.subscribe: This takes a spend public key and a scan private key and return outputs belonging to the them.blockchain.silentpayments.unsubscribe: This takes a spend public key and a scan private key and unsubscribe from notifications.Some context:
This is useful for the PR opened at bitcoindevkit/bdk-sp#48 which is doing integration of frigate ephemeral scanning.
Opening this PR in order to receive feedback.
Reference:
https://github.com/sparrowwallet/frigate/