rust-bitcoin / rust-bitcoincore-rpc

Rust RPC client library for the Bitcoin Core JSON-RPC API.
313 stars 231 forks source link

Allow warnings to be either a string or a string sequence. #353

Closed arik-so closed 1 month ago

arik-so commented 1 month ago

In recent versions of bitcoind, getblockchaininfo returns a result whose warnings key is no longer a string, but an array of strings. This PR allows the parsing of either. Fixes #352.

tcharding commented 1 month ago

Thanks for the fix! I'm going to ack this on the assumption that you tested it because you ran into the problem.

FTR the PR can't be tested because we are so far behind :(

ACK 87c95f6bda73453f12b28ae712e0e396b5401aed

arik-so commented 1 month ago

Thanks so much!

As a matter of fact, I did test it, but to do so, I also added a test module to main.rs and separately ran a local server that returned different values for the warning key based on a switch I could flip. Would it perhaps be helpful to add some unit tests besides the integration tests that could rely on a mock server?

tcharding commented 1 month ago

Legend! You could add some tests if you like but I wouldn't bother putting too much effort in because the whole crate is in need of love.

0xB10C commented 1 month ago

fwiw: this was merged into Bitcoin Core master 2 days ago https://github.com/bitcoin/bitcoin/pull/29845

But I don't think it hurts having this in here early.

arik-so commented 1 month ago

This is wild! My colleague ran into an issue with electrs because of that just yesterday, so must have been particularly unlucky with the timing of cloning bitcoind.