Olaoluwa Osuntokun
4ec8f016b9
rpcclient: fix race condition in doDisconnect
...
In this commit, we fix the following race condition:
```
==================
WARNING: DATA RACE
Write at 0x00c000216018 by goroutine 31:
github.com/btcsuite/btcd/rpcclient.(*Client).wsReconnectHandler()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:736 +0x2aa
github.com/btcsuite/btcd/rpcclient.New·dwrap·13()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1496 +0x39
Previous read at 0x00c000216018 by goroutine 29:
github.com/btcsuite/btcd/rpcclient.(*Client).doDisconnect()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1079 +0x247
github.com/btcsuite/btcd/rpcclient.(*Client).Disconnect()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1111 +0x47
github.com/btcsuite/btcd/rpcclient.(*Client).wsInHandler()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:491 +0x1eb
github.com/btcsuite/btcd/rpcclient.(*Client).start·dwrap·11()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1181 +0x39
Goroutine 31 (running) created at:
github.com/btcsuite/btcd/rpcclient.New()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1496 +0xd77
github.com/btcsuite/btcd/rpcclient.makeClient()
/home/runner/work/btcd/btcd/rpcclient/chain_test.go:268 +0x1f9
github.com/btcsuite/btcd/rpcclient.TestClientConnectedToWSServerRunner.func2()
/home/runner/work/btcd/btcd/rpcclient/chain_test.go:164 +0x47
testing.tRunner()
/opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1259 +0x22f
testing.(*T).Run·dwrap·21()
/opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1306 +0x47
Goroutine 29 (finished) created at:
github.com/btcsuite/btcd/rpcclient.(*Client).start()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1181 +0x2e4
github.com/btcsuite/btcd/rpcclient.New()
/home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1493 +0xc51
github.com/btcsuite/btcd/rpcclient.makeClient()
/home/runner/work/btcd/btcd/rpcclient/chain_test.go:268 +0x1f9
github.com/btcsuite/btcd/rpcclient.TestClientConnectedToWSServerRunner.func2()
/home/runner/work/btcd/btcd/rpcclient/chain_test.go:164 +0x47
testing.tRunner()
/opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1259 +0x22f
testing.(*T).Run·dwrap·21()
/opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1306 +0x47
```
This arises as in `wsReconnectHandler`, the mutex isn't held while the
`conn` pointer is modified.
2023-12-30 16:43:07 -08:00
xiaolou86
4171854739
Fix typos
2023-11-20 12:04:31 -05:00
Olaoluwa Osuntokun
f7e9fba086
Merge pull request #1918 from kcalvinalvin/2022-11-06-implement-getchaintips
...
blockchain, btcjson: Implement getchaintips rpc call
2023-11-14 17:16:15 -08:00
ClaytonNorthey92
d15dd71087
added tests for GetBestBlockHashAsync
...
now testing that GetBestBlockHashAsync sends the getbestblockhash command via websocket connection and that the channel returned can be used to send the response when it is received
2023-11-06 15:56:24 -05:00
ClaytonNorthey92
d988b86027
Added test for client.GetChainTxStatsAsync() in rpcclient. This sets up a test websocket server to run the tests. Also, ensure these are run within a timeout, since they rely on concurrency
2023-11-02 16:16:11 -04:00
ClaytonNorthey92
208800c5f4
Added tests for FutureGetBestBlockHashResult.Receive
2023-11-02 15:17:27 -04:00
yyforyongyu
3a8b851aaf
rpcclient: catch shutdown signal when sending requests
2023-09-04 12:04:32 +08:00
yyforyongyu
d62d537fb5
rpcclient: remove redundant params used in handleSendPostMessage
2023-09-04 12:04:32 +08:00
Calvin Kim
fc99e96b59
rpcclient, integration: Add test for getchaintips call
...
rpcclient now support calling the getchaintips rpc call.
getchaintips_test.go adds test for the getchaintips rpc call. The test
includes hard-coded blocks which the test will feed the node via rpc and
it'll check that the returned chain tips from the getchaintips call
are chaintips that we expect to be returned.
2023-07-16 16:03:50 +09:00
cui fliter
e160bb6922
multi: remove repetitive the
...
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-26 15:40:51 +08:00
Calvin Kim
ba5407615d
multi: Run gofmt on the entire repository
...
The doc formatting changes introduced in the recent go version is
increasing the diff for all of the new commits. Formatting it all in
this commit will help the readability of future PRs by reducing the
diff.
2023-06-21 22:31:09 +09:00
Olaoluwa Osuntokun
8fc2d707f6
Merge pull request #1862 from bhandras/rpccliet-fix2
...
rpcclient: fix missing return
2022-06-06 16:09:32 -07:00
Olaoluwa Osuntokun
1696c63888
Merge pull request #1844 from chappjc/getnewaddress-rpcclient-revert
...
rpcclient: add getnewaddresstype and revert breaking change
2022-06-06 16:08:50 -07:00
Andras Banki-Horvath
b2af7770e9
rpcclient: fix missing return
2022-06-03 14:58:20 +02:00
Andras Banki-Horvath
97313ac873
rpcclient: save the last error when retrying
2022-05-13 15:35:14 +02:00
Andras Banki-Horvath
9babf1fa08
rpcclient: fix backoff logic
...
This commit removes Sleep() from the rety handler so that the shutdown
request is always respected. Furthermore the maximum retry count is corrected.
2022-05-13 15:35:14 +02:00
Andras Banki-Horvath
966511246d
rpclient: fix masked error causing crash after max retries
...
This commit fixes the error that is masked inside the for loop's scope.
Previously after max retries the error didn't leave the for scope and
therefore httpResponse remained nil which in turn resulted in a crash.
2022-05-13 15:35:13 +02:00
Andras Banki-Horvath
ebed1927bf
rpcclient: fix formatting
2022-05-13 15:35:09 +02:00
Jonathan Chappelow
788fb8faf8
rpcclient: add getnewaddresstype and revert breaking change
...
This reverts the previous breaking change to the GetNewAddress and
GetRawChangeAddress rpcclient.Client methods, and adds the methods
GetNewAddressType and GetRawChangeAddressType for requesting
an address of a certain type. This change allows the rpcclient package
to continue to work with versions of the btcwallet app that do not
recognize the address type parameter.
2022-04-14 11:25:56 -05:00
Torkel Rogstad
85b6f7ed2a
rpcclient: add getzmqnotifications RPC
2022-04-09 07:46:07 -04:00
Jonathan Chappelow
7eaf360063
btcjson: add addresstype arg to getrawchangeaddress
2022-04-09 07:38:57 -04:00
Jonathan Chappelow
061aef98af
btcjson: add addresstype arg to getnewaddress
2022-04-09 07:38:57 -04:00
Olaoluwa Osuntokun
caac0f821a
multi: update btcutil imports to point to new sub-module
...
In this commit, we update all the btcutil imports to point to the new
sub-module.
In the same commit, we also modify the recently added `btcutil/go.mod`
file as we need to continue pointing to the _old_ version of btcd, until
we merge this PR and push a new tag.
2022-01-10 18:44:58 -08:00
Matthew Bajorek
ec9ca7d782
rpcclient+rpcserver: Change getnetworkhashps return type to be a float to be in line with bitcoin core
2021-12-14 10:05:52 -05:00
3nprob
cc7327c194
rpcclient: Add retry with backoffs to HTTP POST requests
...
Adds behavior similar to the retries of persistent RPC connections
to HTTP request.
* Initial backoff: 500ms
* Linear increase
* Max retries: 10
Room for future improvement:
* Make configurable
* Add jitter
* Tests for retry behavior
2021-11-16 09:08:07 -05:00
JeremyRand
3e2d8464f1
rpcclient: Export symbols needed for custom commands ( #1457 )
...
* rpcclient: Export sendCmd and response
This facilitates using custom commands with rpcclient.
See https://github.com/btcsuite/btcd/issues/1083
* rpcclient: Export receiveFuture
This facilitates using custom commands with rpcclient.
See https://github.com/btcsuite/btcd/issues/1083
* rpcclient: Add customcommand example
* rpcclient: remove "Namecoin" from customcommand readme heading
2021-09-02 08:39:55 +02:00
Jake Sylvestre
540786fda6
rpcclient: fix documentation typo
2021-04-13 09:09:20 -04:00
Jake Sylvestre
d08785547a
docs: update shields
2021-03-05 07:45:19 -05:00
Jake Sylvestre
2a1aa5129e
Add Batch JSON-RPC support (rpc client & server)
2021-02-09 09:47:46 -05:00
10gic
610bb55ae8
rpcclient: add ExtraHeaders in ConnConfig
2020-11-24 14:15:14 -05:00
Armando Ochoa
f070f7f2be
rpcclient: fix documentation typos
2020-11-04 09:56:02 -05:00
Anirudha Bose
535f25593d
rpcclient: implement createwallet with functional options
2020-10-26 14:54:05 -04:00
Torkel Rogstad
1d75e0a885
rpcclient: add more wallet commands
...
Implement backupwallet, dumpwallet, loadwallet and unloadwallet.
2020-10-26 09:34:56 -04:00
Anirudha Bose
6519c04a6f
rpcclient: implement gettxoutsetinfo command
2020-10-05 10:03:47 -04:00
Henry Fisher
584c382334
rpc: add signrawtransactionwithwallet interface
...
Adds interface for issuing a signrawtransactionwithwallet command.
Note that this does not add functionality for the btcd rpc server
itself, it simply assumes that the RPC client has this ability and gives
an API for interacting with the RPC client.
rpc: add signrawtransactionwithwallet interface
2020-10-05 09:56:12 -04:00
Anirudha Bose
e9a51e8dcd
rpcclient: implement getwalletinfo command
2020-09-25 12:18:06 -04:00
Anirudha Bose
ac3f235eb9
rpcclient: implement getaddressinfo command
...
Fields such as label, and labelspurpose are not included, since they
are deprecated, and will be removed in Bitcoin Core 0.21.
2020-09-21 09:47:58 -04:00
Elliott Minns
6daaf73544
GetBlockTemplate RPC client implementation ( #1629 )
...
* GetBlockTemplate RPC client implementation
* Txid added to the getblocktemplate result
* Omitempty for TxID and improved comment for GetBlockTemplate 'rules' field
2020-09-21 09:42:35 -04:00
Anirudha Bose
c693bd8bc5
rpcclient: add deriveaddresses RPC command
2020-09-14 10:30:47 -04:00
Andrew Tugarinov
5ae1f21cd9
Added ListSinceBlockMinConfWatchOnly method.
2020-09-14 09:48:40 -04:00
Federico Bond
6f49f1f194
btcjson,rpcclient: add support for PSBT commands to rpcclient
2020-09-14 09:37:27 -04:00
Mikael Lindlof
fff96610aa
rpc: Add getnodeaddresses JSON-RPC support
...
Add NodeAddresses function to rpcserverConnManager
interface for fetching known node addresses.
2020-09-14 09:36:05 -04:00
Anirudha Bose
ba3fe57507
rpcclient: support listtransactions RPC with watchonly argument
...
Co-authored-by: Gert-Jaap Glasbergen <gertjaap@decoscrypto.com>
2020-09-08 09:43:02 -04:00
Anirudha Bose
fffe4a909b
rpcclient: Implement importmulti JSON-RPC client command
2020-08-31 15:28:48 -04:00
Mikael Lindlof
b68c50e33c
Add getblockfilter JSON-RPC client command
...
Add type for second getblockfilter param
2020-08-31 10:02:54 -04:00
Anirudha Bose
efae8e9967
Add rpclient implementation of getdescriptorinfo RPC
2020-08-31 09:41:49 -04:00
Anirudha Bose
e2d9cf4b55
rpcclient: Add GetTransactionWatchOnly method
2020-06-29 10:15:10 -04:00
Federico Bond
7b2ff5d180
Add getbalances RPC client command
2020-06-29 10:14:04 -04:00
Torkel Rogstad
e4f59022a3
Add fundrawtransaction RPC call
2020-06-15 09:44:04 -04:00
Mikael Lindlof
73d69f09d0
Add getchaintxstats JSON-RPC client command
2020-06-15 09:42:37 -04:00