File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313#include <plugins/libplugin.h>
1414#include <unistd.h>
1515
16+ /* Bitcoin Core RPC error code for duplicate transaction */
1617#define RPC_TRANSACTION_ALREADY_IN_CHAIN -27
1718
19+ /* Hex-encoded SHA256 block hash length (32 bytes = 64 hex chars) */
20+ #define BLOCK_HASH_HEX_LEN 64
21+
22+ /* Bitcoin Core version 23.0.0 introduced getblockfrompeer RPC */
23+ #define BITCOIND_VERSION_GETBLOCKFROMPEER 230000
24+
1825struct bitcoind {
1926 /* eg. "bitcoin-cli" */
2027 char * cli ;
@@ -348,7 +355,7 @@ static struct command_result *getrawblockbyheight(struct command *cmd,
348355 }
349356
350357 strip_trailing_whitespace (res -> output , res -> output_len );
351- if (strlen (res -> output ) != 64 )
358+ if (strlen (res -> output ) != BLOCK_HASH_HEX_LEN )
352359 return command_err (cmd , res , "bad JSON: bad blockhash" );
353360
354361 block_hash = tal_strdup (cmd , res -> output );
@@ -382,7 +389,7 @@ static struct command_result *getrawblockbyheight(struct command *cmd,
382389 }
383390
384391 /* Try fetching from peers if bitcoind >= 23.0.0 */
385- if (bitcoind -> version >= 230000 ) {
392+ if (bitcoind -> version >= BITCOIND_VERSION_GETBLOCKFROMPEER ) {
386393 if (!peers )
387394 peers = get_fullnode_peers (cmd , cmd );
388395
You can’t perform that action at this time.
0 commit comments