Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions integration_test/tests/generating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ fn generating__generate_block__modelled() {
{
// No `submit` argument
json = node.client.generate_block(&mining_addr.to_string(), &transactions).expect("generateblock");
let model: Result<mtype::GenerateBlock, _> = json.into_model();
model.unwrap();
}

#[cfg(not(feature = "v24_and_below"))]
{
// Check with `submit = false` so that `hex` is returned. v25 and later only.
json = node.client.generate_block(&mining_addr.to_string(), &transactions, false).expect("generateblock");
let model: Result<mtype::GenerateBlock, GenerateBlockError> = json.into_model();
model.unwrap();
}
let model: Result<mtype::GenerateBlock, GenerateBlockError> = json.into_model();
model.unwrap();
}

#[test]
Expand Down
35 changes: 0 additions & 35 deletions types/src/v21/generating/error.rs

This file was deleted.

10 changes: 4 additions & 6 deletions types/src/v21/generating/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
//!
//! Types for methods found under the `== Generating ==` section of the API docs.

use bitcoin::BlockHash;
use bitcoin::{hex, BlockHash};

use super::{GenerateBlock, GenerateBlockError};
use super::GenerateBlock;
use crate::model;

impl GenerateBlock {
/// Converts version specific type to a version nonspecific, more strongly typed type.
pub fn into_model(self) -> Result<model::GenerateBlock, GenerateBlockError> {
use GenerateBlockError as E;

let hash = self.hash.parse::<BlockHash>().map_err(E::Hash)?;
pub fn into_model(self) -> Result<model::GenerateBlock, hex::HexToArrayError> {
let hash = self.hash.parse::<BlockHash>()?;
Ok(model::GenerateBlock {
hash,
hex: None, // v25 and later only.
Expand Down
3 changes: 0 additions & 3 deletions types/src/v21/generating/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
//!
//! Types for methods found under the `== Generating ==` section of the API docs.

mod error;
mod into;

use serde::{Deserialize, Serialize};

pub use self::error::GenerateBlockError;

/// Result of JSON-RPC method `generateblock`.
///
/// > Mine a block with a set of ordered transactions immediately to a specified address or descriptor (before the RPC call returns)
Expand Down
2 changes: 1 addition & 1 deletion types/src/v21/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub use self::{
Bip9SoftforkInfo, GetBlockchainInfo, GetMempoolEntry, GetMempoolInfo, Softfork,
SoftforkType,
},
generating::{GenerateBlock, GenerateBlockError},
generating::GenerateBlock,
network::{GetNetworkInfo, GetPeerInfo},
util::{GetIndexInfo, GetIndexInfoName},
wallet::{
Expand Down
7 changes: 3 additions & 4 deletions types/src/v22/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,9 @@ pub use crate::{
},
v20::{CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail},
v21::{
Bip9SoftforkInfo, GenerateBlock, GenerateBlockError, GetBlockchainInfo, GetIndexInfo,
GetIndexInfoName, GetMempoolEntry, GetNetworkInfo, ImportDescriptors,
ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, Softfork,
SoftforkType, UnloadWallet, UpgradeWallet,
Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, GetIndexInfoName,
GetMempoolEntry, GetNetworkInfo, ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee,
PsbtBumpFeeError, Send, SendError, Softfork, SoftforkType, UnloadWallet, UpgradeWallet,
},
ScriptPubkey,
};
6 changes: 3 additions & 3 deletions types/src/v23/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ pub use crate::{
},
v20::{GenerateToDescriptor, GetTransactionDetail},
v21::{
GenerateBlock, GenerateBlockError, GetIndexInfo, GetIndexInfoName, GetNetworkInfo,
ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError,
UnloadWallet, UpgradeWallet,
GenerateBlock, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors,
ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UnloadWallet,
UpgradeWallet,
},
v22::{Banned, GetMempoolInfo, ListBanned, ScriptPubkey},
};
6 changes: 3 additions & 3 deletions types/src/v24/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ pub use crate::{
},
v20::GenerateToDescriptor,
v21::{
GenerateBlock, GenerateBlockError, GetIndexInfo, GetIndexInfoName, GetNetworkInfo,
ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError,
UnloadWallet, UpgradeWallet,
GenerateBlock, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors,
ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UnloadWallet,
UpgradeWallet,
},
v22::{Banned, ListBanned, ScriptPubkey},
v23::{
Expand Down