From e68d4f960f929d85f4121e324a9fcdbd017789c5 Mon Sep 17 00:00:00 2001 From: Afshin Arani Date: Thu, 9 Feb 2023 14:25:21 +0330 Subject: [PATCH] Backend: electrumServer's IdFromPos support (#205) This is used for our RgsToElectrumServerMiddleware code, see: https://github.com/nblockchain/rapid-gossip-sync-server/pull/1 --- .../UtxoCoin/ElectrumClient.fs | 7 +++++++ src/GWallet.Backend/UtxoCoin/StratumClient.fs | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs b/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs index 5059f4ec2..14bca3c32 100644 --- a/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs +++ b/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs @@ -83,6 +83,13 @@ module ElectrumClient = return blockchainTransactionResult.Result } + // DON'T DELETE, used in external projects + let GetBlockchainTransactionIdFromPos (height: UInt32) (txPos: UInt32) (stratumServer: Async) = async { + let! stratumClient = stratumServer + let! blockchainTransactionResult = stratumClient.BlockchainTransactionIdFromPos height txPos + return blockchainTransactionResult.Result + } + let EstimateFee (numBlocksTarget: int) (stratumServer: Async): Async = async { let! stratumClient = stratumServer let! estimateFeeResult = stratumClient.BlockchainEstimateFee numBlocksTarget diff --git a/src/GWallet.Backend/UtxoCoin/StratumClient.fs b/src/GWallet.Backend/UtxoCoin/StratumClient.fs index 350d8f7d7..fa0ec3b65 100644 --- a/src/GWallet.Backend/UtxoCoin/StratumClient.fs +++ b/src/GWallet.Backend/UtxoCoin/StratumClient.fs @@ -51,6 +51,13 @@ type BlockchainTransactionGetResult = Result: string; } +// DON'T DELETE, used in external projects +type BlockchainTransactionIdFromPosResult = + { + Id: int + Result: string + } + type BlockchainEstimateFeeResult = { Id: int; @@ -258,6 +265,19 @@ type StratumClient (jsonRpcClient: JsonRpcTcpClient) = return resObj } + // DON'T DELETE, used in external projects + member self.BlockchainTransactionIdFromPos height txPos: Async = + let obj = { + Id = 0; + Method = "blockchain.transaction.id_from_pos"; + Params = [height :> obj; txPos :> obj] + } + let json = Serialize obj + async { + let! resObj,_ = self.Request json + return resObj + } + // NOTE: despite Electrum-X official docs claiming that this method is deprecated... it's not! go read the official // non-shitcoin forked version of the docs: https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-methods.html#blockchain-estimatefee member self.BlockchainEstimateFee (numBlocksTarget: int): Async =