Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Add support for Bitcoin Core v27
Browse files Browse the repository at this point in the history
Add support and testing for Bitcoin Core versions `27.0` and `27.1`.
  • Loading branch information
tcharding committed Aug 29, 2024
1 parent ef0fc39 commit ad04577
Show file tree
Hide file tree
Showing 14 changed files with 561 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ jobs:
matrix:
feature:
[
"27_1",
"27_0",
"26_2",
"26_1",
"26_0",
Expand Down
1 change: 1 addition & 0 deletions client/src/client_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod v23;
pub mod v24;
pub mod v25;
pub mod v26;
pub mod v27;

use std::fs::File;
use std::io::{BufRead, BufReader};
Expand Down
44 changes: 44 additions & 0 deletions client/src/client_sync/v27.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: CC0-1.0

//! A JSON-RPC client for testing against Bitcoin Core `v27`.
//!
//! We ignore option arguments unless they effect the shape of the returned JSON data.
use bitcoin::address::{Address, NetworkChecked};
use bitcoin::{Amount, Block, BlockHash, Txid};

use crate::client_sync::{handle_defaults, into_json};
use crate::json::v27::*;

crate::define_jsonrpc_minreq_client!("v27");

// == Blockchain ==
crate::impl_client_v17__getblockchaininfo!();
crate::impl_client_v17__getbestblockhash!();
crate::impl_client_v17__getblock!();
crate::impl_client_v17__gettxout!();

// == Control ==
crate::impl_client_v17__stop!();

// == Generating ==
crate::impl_client_v17__generatetoaddress!();

// == Network ==
crate::impl_client_v17__getnetworkinfo!();
crate::impl_client_check_expected_server_version!({ [270000, 270100] });

// == Rawtransactions ==
crate::impl_client_v17__sendrawtransaction!();

// == Wallet ==
crate::impl_client_v17__createwallet!();
crate::impl_client_v22__unloadwallet!();
crate::impl_client_v22__loadwallet!();
crate::impl_client_v17__getbalance!();
crate::impl_client_v19__getbalances!();
crate::impl_client_v17__getnewaddress!();
crate::impl_client_v17__sendtoaddress!();
crate::impl_client_v17__gettransaction!();

pub use crate::client_sync::v23::AddressType;
7 changes: 7 additions & 0 deletions contrib/run_bitcoind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COMMAND
- stop Kill all bitcoind nodes using 'pkill bitcoind'.
KNOWN_VERSION
- v27 Bitcoin Core v27.1
- v26 Bitcoin Core v26.2
- v25 Bitcoin Core v25.2
- v24 Bitcoin Core v24.2
Expand All @@ -48,6 +49,7 @@ main() {

case $cmd in
all)
start "v27" # 27.1
start "v26" # 26.2
start "v25" # 25.2
start "v24" # 24.2
Expand Down Expand Up @@ -82,6 +84,11 @@ start() {
local version="$1"

case $version in
v27)
local version_number="27.1"
local version_id="271"
;;

v26)
local version_number="26.2"
local version_id="262"
Expand Down
3 changes: 3 additions & 0 deletions integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ edition = "2021"
[features]
# Enable the same feature in `bitcoind` and the version feature here.
# All minor releases (but only the latest patch release).
"27_1" = ["v27", "bitcoind/27_1"]
"27_0" = ["v27", "bitcoind/27_0"]
"26_2" = ["v26", "bitcoind/26_2"]
"26_1" = ["v26", "bitcoind/26_1"]
"26_0" = ["v26", "bitcoind/26_0"]
Expand All @@ -35,6 +37,7 @@ edition = "2021"
"0_17_1" = ["v17", "bitcoind/0_17_1"]

# Each minor version is tested with the same client.
"v27" = []
"v26" = []
"v25" = []
"v24" = []
Expand Down
57 changes: 57 additions & 0 deletions integration_test/tests/v27_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//! Test the JSON-RPC API against `bitcoind v27.1`.
#![cfg(feature = "v27")]

use integration_test::*;

// == Blockchain ==
mod blockchain {
use super::*;

impl_test_v17__getblockchaininfo!();
impl_test_v17__getbestblockhash!();
impl_test_v17__getblock_verbosity_0!();
impl_test_v17__getblock_verbosity_1!();
}

// == Control ==
mod control {
use super::*;

impl_test_v17__stop!();
}

// == Generating ==
mod generating {
use super::*;

impl_test_v17__generatetoaddress!();
}

// == Network ==
mod network {
use super::*;

impl_test_v17__getnetworkinfo!();
}

// == Rawtransactions ==
mod raw_transactions {
use super::*;

impl_test_v17__sendrawtransaction!();
}

// == Wallet ==
mod wallet {
use super::*;

impl_test_v17__createwallet!();
impl_test_v17__loadwallet!();

impl_test_v17__getnewaddress!();
impl_test_v17__getbalance!();
impl_test_v19__getbalances!();
impl_test_v17__sendtoaddress!();
impl_test_v17__gettransaction!();
}
1 change: 1 addition & 0 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod v23;
pub mod v24;
pub mod v25;
pub mod v26;
pub mod v27;

// JSON types that model _all_ `bitcoind` versions.
pub mod model;
195 changes: 195 additions & 0 deletions json/src/v27/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
// SPDX-License-Identifier: CC0-1.0

//! Structs with standard types.
//!
//! These structs model the types returned by the JSON-RPC API and use stdlib types (or custom
//! types) and are specific to a specific to Bitcoin Core `v27`.
//!
//! **== Blockchain ==**
//! - [ ] `dumptxoutset "path"`
//! - [x] `getbestblockhash`
//! - [x] `getblock "blockhash" ( verbosity )`
//! - [x] `getblockchaininfo`
//! - [ ] `getblockcount`
//! - [ ] `getblockfilter "blockhash" ( "filtertype" )`
//! - [ ] `getblockfrompeer "blockhash" peer_id`
//! - [ ] `getblockhash height`
//! - [ ] `getblockheader "blockhash" ( verbose )`
//! - [ ] `getblockstats hash_or_height ( stats )`
//! - [ ] `getchainstates`
//! - [ ] `getchaintips`
//! - [ ] `getchaintxstats ( nblocks "blockhash" )`
//! - [ ] `getdeploymentinfo ( "blockhash" )`
//! - [ ] `getdifficulty`
//! - [ ] `getmempoolancestors "txid" ( verbose )`
//! - [ ] `getmempooldescendants "txid" ( verbose )`
//! - [ ] `getmempoolentry "txid"`
//! - [ ] `getmempoolinfo`
//! - [ ] `getrawmempool ( verbose mempool_sequence )`
//! - [ ] `gettxout "txid" n ( include_mempool )`
//! - [ ] `gettxoutproof ["txid",...] ( "blockhash" )`
//! - [ ] `gettxoutsetinfo ( "hash_type" hash_or_height use_index )`
//! - [ ] `gettxspendingprevout [{"txid":"hex","vout":n},...]`
//! - [ ] `importmempool "filepath" ( options )`
//! - [ ] `loadtxoutset "path"`
//! - [ ] `preciousblock "blockhash"`
//! - [ ] `pruneblockchain height`
//! - [ ] `savemempool`
//! - [ ] `scanblocks "action" ( [scanobjects,...] start_height stop_height "filtertype" options )`
//! - [ ] `scantxoutset "action" ( [scanobjects,...] )`
//! - [ ] `verifychain ( checklevel nblocks )`
//! - [ ] `verifytxoutproof "proof"`
//!
//! **== Control ==**
//! - [ ] `getmemoryinfo ( "mode" )`
//! - [ ] `getrpcinfo`
//! - [ ] `help ( "command" )`
//! - [ ] `logging ( ["include_category",...] ["exclude_category",...] )`
//! - [x] `stop`
//! - [ ] `uptime`
//!
//! **== Mining ==**
//! - [ ] `getblocktemplate {"mode":"str","capabilities":["str",...],"rules":["segwit","str",...],"longpollid":"str","data":"hex"}`
//! - [ ] `getmininginfo`
//! - [ ] `getnetworkhashps ( nblocks height )`
//! - [ ] `getprioritisedtransactions`
//! - [ ] `prioritisetransaction "txid" ( dummy ) fee_delta`
//! - [ ] `submitblock "hexdata" ( "dummy" )`
//! - [ ] `submitheader "hexdata"`
//!
//! **== Network ==**
//! - [ ] `addnode "node" "command" ( v2transport )`
//! - [ ] `clearbanned`
//! - [ ] `disconnectnode ( "address" nodeid )`
//! - [ ] `getaddednodeinfo ( "node" )`
//! - [ ] `getaddrmaninfo`
//! - [ ] `getconnectioncount`
//! - [ ] `getnettotals`
//! - [ ] `getnetworkinfo`
//! - [ ] `getnodeaddresses ( count "network" )`
//! - [ ] `getpeerinfo`
//! - [ ] `listbanned`
//! - [ ] `ping`
//! - [ ] `setban "subnet" "command" ( bantime absolute )`
//! - [ ] `setnetworkactive state`
//!
//! **== Rawtransactions ==**
//! - [ ] `analyzepsbt "psbt"`
//! - [ ] `combinepsbt ["psbt",...]`
//! - [ ] `combinerawtransaction ["hexstring",...]`
//! - [ ] `converttopsbt "hexstring" ( permitsigdata iswitness )`
//! - [ ] `createpsbt [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount,...},{"data":"hex"},...] ( locktime replaceable )`
//! - [ ] `createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount,...},{"data":"hex"},...] ( locktime replaceable )`
//! - [ ] `decodepsbt "psbt"`
//! - [ ] `decoderawtransaction "hexstring" ( iswitness )`
//! - [ ] `decodescript "hexstring"`
//! - [ ] `descriptorprocesspsbt "psbt" ["",{"desc":"str","range":n or [n,n]},...] ( "sighashtype" bip32derivs finalize )`
//! - [ ] `finalizepsbt "psbt" ( extract )`
//! - [ ] `fundrawtransaction "hexstring" ( options iswitness )`
//! - [ ] `getrawtransaction "txid" ( verbosity "blockhash" )`
//! - [ ] `joinpsbts ["psbt",...]`
//! - [ ] `sendrawtransaction "hexstring" ( maxfeerate maxburnamount )`
//! - [ ] `signrawtransactionwithkey "hexstring" ["privatekey",...] ( [{"txid":"hex","vout":n,"scriptPubKey":"hex","redeemScript":"hex","witnessScript":"hex","amount":amount},...] "sighashtype" )`
//! - [ ] `submitpackage ["rawtx",...]`
//! - [ ] `testmempoolaccept ["rawtx",...] ( maxfeerate )`
//! - [ ] `utxoupdatepsbt "psbt" ( ["",{"desc":"str","range":n or [n,n]},...] )`
//!
//! **== Signer ==**
//! - [ ] `enumeratesigners`
//!
//! **== Util ==**
//! - [ ] `createmultisig nrequired ["key",...] ( "address_type" )`
//! - [ ] `deriveaddresses "descriptor" ( range )`
//! - [ ] `estimatesmartfee conf_target ( "estimate_mode" )`
//! - [ ] `getdescriptorinfo "descriptor"`
//! - [ ] `getindexinfo ( "index_name" )`
//! - [ ] `signmessagewithprivkey "privkey" "message"`
//! - [ ] `validateaddress "address"`
//! - [ ] `verifymessage "address" "signature" "message"`
//!
//! **== Wallet ==**
//! - [ ] `abandontransaction "txid"`
//! - [ ] `abortrescan`
//! - [ ] `addmultisigaddress nrequired ["key",...] ( "label" "address_type" )`
//! - [ ] `backupwallet "destination"`
//! - [ ] `bumpfee "txid" ( options )`
//! - [ ] `createwallet "wallet_name" ( disable_private_keys blank "passphrase" avoid_reuse descriptors load_on_startup external_signer )`
//! - [ ] `dumpprivkey "address"`
//! - [ ] `dumpwallet "filename"`
//! - [ ] `encryptwallet "passphrase"`
//! - [ ] `getaddressesbylabel "label"`
//! - [ ] `getaddressinfo "address"`
//! - [x] `getbalance ( "dummy" minconf include_watchonly avoid_reuse )`
//! - [x] `getbalances`
//! - [x] `getnewaddress ( "label" "address_type" )`
//! - [ ] `getrawchangeaddress ( "address_type" )`
//! - [ ] `getreceivedbyaddress "address" ( minconf include_immature_coinbase )`
//! - [ ] `getreceivedbylabel "label" ( minconf include_immature_coinbase )`
//! - [x] `gettransaction "txid" ( include_watchonly verbose )`
//! - [ ] `getunconfirmedbalance`
//! - [ ] `getwalletinfo`
//! - [ ] `importaddress "address" ( "label" rescan p2sh )`
//! - [ ] `importdescriptors requests`
//! - [ ] `importmulti requests ( options )`
//! - [ ] `importprivkey "privkey" ( "label" rescan )`
//! - [ ] `importprunedfunds "rawtransaction" "txoutproof"`
//! - [ ] `importpubkey "pubkey" ( "label" rescan )`
//! - [ ] `importwallet "filename"`
//! - [ ] `keypoolrefill ( newsize )`
//! - [ ] `listaddressgroupings`
//! - [ ] `listdescriptors ( private )`
//! - [ ] `listlabels ( "purpose" )`
//! - [ ] `listlockunspent`
//! - [ ] `listreceivedbyaddress ( minconf include_empty include_watchonly "address_filter" include_immature_coinbase )`
//! - [ ] `listreceivedbylabel ( minconf include_empty include_watchonly include_immature_coinbase )`
//! - [ ] `listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed include_change "label" )`
//! - [ ] `listtransactions ( "label" count skip include_watchonly )`
//! - [ ] `listunspent ( minconf maxconf ["address",...] include_unsafe query_options )`
//! - [ ] `listwalletdir`
//! - [ ] `listwallets`
//! - [x] `loadwallet "filename" ( load_on_startup )`
//! - [ ] `lockunspent unlock ( [{"txid":"hex","vout":n},...] persistent )`
//! - [ ] `migratewallet ( "wallet_name" "passphrase" )`
//! - [ ] `newkeypool`
//! - [ ] `psbtbumpfee "txid" ( options )`
//! - [ ] `removeprunedfunds "txid"`
//! - [ ] `rescanblockchain ( start_height stop_height )`
//! - [ ] `restorewallet "wallet_name" "backup_file" ( load_on_startup )`
//! - [ ] `send [{"address":amount,...},{"data":"hex"},...] ( conf_target "estimate_mode" fee_rate options )`
//! - [ ] `sendall ["address",{"address":amount,...},...] ( conf_target "estimate_mode" fee_rate options )`
//! - [ ] `sendmany ( "" ) {"address":amount,...} ( minconf "comment" ["address",...] replaceable conf_target "estimate_mode" fee_rate verbose )`
//! - [x] `sendtoaddress "address" amount ( "comment" "comment_to" subtractfeefromamount replaceable conf_target "estimate_mode" avoid_reuse fee_rate verbose )`
//! - [ ] `sethdseed ( newkeypool "seed" )`
//! - [ ] `setlabel "address" "label"`
//! - [ ] `settxfee amount`
//! - [ ] `setwalletflag "flag" ( value )`
//! - [ ] `signmessage "address" "message"`
//! - [ ] `signrawtransactionwithwallet "hexstring" ( [{"txid":"hex","vout":n,"scriptPubKey":"hex","redeemScript":"hex","witnessScript":"hex","amount":amount},...] "sighashtype" )`
//! - [ ] `simulaterawtransaction ( ["rawtx",...] {"include_watchonly":bool,...} )`
//! - [ ] `unloadwallet ( "wallet_name" load_on_startup )`
//! - [ ] `upgradewallet ( version )`
//! - [ ] `walletcreatefundedpsbt ( [{"txid":"hex","vout":n,"sequence":n,"weight":n},...] ) [{"address":amount,...},{"data":"hex"},...] ( locktime options bip32derivs )`
//! - [ ] `walletdisplayaddress "address"`
//! - [ ] `walletlock`
//! - [ ] `walletpassphrase "passphrase" timeout`
//! - [ ] `walletpassphrasechange "oldpassphrase" "newpassphrase"`
//! - [ ] `walletprocesspsbt "psbt" ( sign "sighashtype" bip32derivs finalize )`
//!
//! **== Zmq ==**
//! - [ ] `getzmqnotifications`
#[doc(inline)]
pub use crate::{
v17::{
GenerateToAddress, GetBalance, GetBestBlockHash, GetBlockVerbosityOne,
GetBlockVerbosityZero, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork,
GetNewAddress, GetTransaction, GetTransactionDetail, GetTransactionDetailCategory,
GetTxOut, SendRawTransaction,
},
v19::{
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesMine,
GetBalancesWatchOnly, GetBlockchainInfo, Softfork, SoftforkType,
},
v22::{SendToAddress, UnloadWallet},
v25::{CreateWallet, LoadWallet},
};
Loading

0 comments on commit ad04577

Please sign in to comment.