Skip to content

Commit

Permalink
Backend: electrumServer's IdFromPos support (#205)
Browse files Browse the repository at this point in the history
This is used for our RgsToElectrumServerMiddleware code, see:
nblockchain/rapid-gossip-sync-server#1
  • Loading branch information
aarani authored Feb 9, 2023
1 parent f5b1eff commit e68d4f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/GWallet.Backend/UtxoCoin/ElectrumClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ module ElectrumClient =
return blockchainTransactionResult.Result
}

// DON'T DELETE, used in external projects
let GetBlockchainTransactionIdFromPos (height: UInt32) (txPos: UInt32) (stratumServer: Async<StratumClient>) = async {
let! stratumClient = stratumServer
let! blockchainTransactionResult = stratumClient.BlockchainTransactionIdFromPos height txPos
return blockchainTransactionResult.Result
}

let EstimateFee (numBlocksTarget: int) (stratumServer: Async<StratumClient>): Async<decimal> = async {
let! stratumClient = stratumServer
let! estimateFeeResult = stratumClient.BlockchainEstimateFee numBlocksTarget
Expand Down
20 changes: 20 additions & 0 deletions src/GWallet.Backend/UtxoCoin/StratumClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -258,6 +265,19 @@ type StratumClient (jsonRpcClient: JsonRpcTcpClient) =
return resObj
}

// DON'T DELETE, used in external projects
member self.BlockchainTransactionIdFromPos height txPos: Async<BlockchainTransactionIdFromPosResult> =
let obj = {
Id = 0;
Method = "blockchain.transaction.id_from_pos";
Params = [height :> obj; txPos :> obj]
}
let json = Serialize obj
async {
let! resObj,_ = self.Request<BlockchainTransactionIdFromPosResult> 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<BlockchainEstimateFeeResult> =
Expand Down

0 comments on commit e68d4f9

Please sign in to comment.