From 650f198f845948a1c283aef13a54aa64b81fdb88 Mon Sep 17 00:00:00 2001 From: Joshua Sing Date: Tue, 27 Feb 2024 02:23:29 +1100 Subject: [PATCH] Fix race condition in electrumx client Previously, the request ID stored in the client was incremented while the lock was held, however it was then read without the lock being held. --- hemi/electrumx/electrumx.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hemi/electrumx/electrumx.go b/hemi/electrumx/electrumx.go index aa8d25bd1..2e9ed23f2 100644 --- a/hemi/electrumx/electrumx.go +++ b/hemi/electrumx/electrumx.go @@ -124,12 +124,13 @@ func (c *Client) call(ctx context.Context, method string, params, result any) er c.mtx.Lock() c.id++ + id := c.id c.mtx.Unlock() req := &JSONRPCRequest{ JSONRPC: "2.0", Method: method, - ID: c.id, + ID: id, } if params != any(nil) { b, err := json.Marshal(params)