-
Notifications
You must be signed in to change notification settings - Fork 33
Address all TODO in v24 #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8610326
Add gettxspendingprevout method, model and test
jamillambert 5adeeae
Add sendall method, model and test
jamillambert 976bb9e
Increase client timeout
jamillambert 3a9e9be
Add migratewallet method and test
jamillambert 2125b02
Add simulaterawtransaction method, model and test
jamillambert 78cbbdc
Run the formatter
jamillambert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
//! Macros for implementing JSON-RPC methods on a client. | ||
//! | ||
//! Specifically this is methods found under the `== Blockchain ==` section of the | ||
//! API docs of Bitcoin Core `v24`. | ||
//! | ||
//! All macros require `Client` to be in scope. | ||
//! | ||
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. | ||
|
||
/// Implements Bitcoin Core JSON-RPC API method `gettxspendingprevout` | ||
#[macro_export] | ||
macro_rules! impl_client_v24__get_tx_spending_prevout { | ||
() => { | ||
impl Client { | ||
pub fn get_tx_spending_prevout( | ||
&self, | ||
outputs: &[bitcoin::OutPoint], | ||
) -> Result<GetTxSpendingPrevout> { | ||
let json_outputs: Vec<_> = outputs.iter().map(|out| { | ||
serde_json::json!({ | ||
"txid": out.txid.to_string(), | ||
"vout": out.vout, | ||
}) | ||
}).collect(); | ||
self.call("gettxspendingprevout", &[json_outputs.into()]) | ||
} | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
//! Macros for implementing JSON-RPC methods on a client. | ||
//! | ||
//! Specifically this is methods found under the `== Wallet ==` section of the | ||
//! API docs of Bitcoin Core `v24`. | ||
//! | ||
//! All macros require `Client` to be in scope. | ||
//! | ||
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. | ||
|
||
/// Implements Bitcoin Core JSON-RPC API method `migratewallet`. | ||
#[macro_export] | ||
macro_rules! impl_client_v24__migrate_wallet { | ||
() => { | ||
impl Client { | ||
pub fn migrate_wallet(&self, wallet_name: &str) -> Result<MigrateWallet> { | ||
self.call("migratewallet", &[wallet_name.into()]) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
/// Implements Bitcoin Core JSON-RPC API method `sendall`. | ||
#[macro_export] | ||
macro_rules! impl_client_v24__send_all { | ||
() => { | ||
impl Client { | ||
pub fn send_all(&self, recipients: &[Address]) -> Result<SendAll> { | ||
self.call("sendall", &[into_json(recipients)?]) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
/// Implements Bitcoin Core JSON-RPC API method `simulaterawtransaction`. | ||
#[macro_export] | ||
macro_rules! impl_client_v24__simulate_raw_transaction { | ||
() => { | ||
impl Client { | ||
pub fn simulate_raw_transaction( | ||
&self, | ||
rawtxs: &[String], | ||
) -> Result<SimulateRawTransaction> { | ||
self.call("simulaterawtransaction", &[into_json(rawtxs)?]) | ||
} | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is odd here, we should be able to use
into_json(out)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I tried first but got the error "JSON value of type string is not of expected type object".
into_json(outputs) gives:
json_outputs
that works as an argument for the RPC is:Using into_json on the OutPoint directly make a single field
txid:vout
not separate likejson_outputs
above.