Skip to content

Commit

Permalink
Create rpc client after updating index (ordinals#1731)
Browse files Browse the repository at this point in the history
Co-authored-by: raphjaph <raphjaph@protonmail.com>
  • Loading branch information
andrewtoth and raphjaph authored Feb 21, 2023
1 parent cd23ef9 commit 0c1a6fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ pub(crate) struct Inscribe {

impl Inscribe {
pub(crate) fn run(self, options: Options) -> Result {
let client = options.bitcoin_rpc_client_for_wallet_command(false)?;

let inscription = Inscription::from_file(options.chain(), &self.file)?;

let index = Index::open(&options)?;
index.update()?;

let client = options.bitcoin_rpc_client_for_wallet_command(false)?;

let mut utxos = index.get_unspent_outputs(Wallet::load(&options)?)?;

let inscriptions = index.get_inscriptions(None)?;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/wallet/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pub struct Output {

impl Send {
pub(crate) fn run(self, options: Options) -> Result {
let client = options.bitcoin_rpc_client_for_wallet_command(false)?;

if !self.address.is_valid_for_network(options.chain().network()) {
bail!(
"Address `{}` is not valid for {}",
Expand All @@ -28,6 +26,8 @@ impl Send {
let index = Index::open(&options)?;
index.update()?;

let client = options.bitcoin_rpc_client_for_wallet_command(false)?;

let unspent_outputs = index.get_unspent_outputs(Wallet::load(&options)?)?;

let inscriptions = index.get_inscriptions(None)?;
Expand Down
1 change: 1 addition & 0 deletions tests/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn inscribe_fails_if_bitcoin_core_is_too_old() {
let rpc_server = test_bitcoincore_rpc::builder().version(230000).build();

CommandBuilder::new("wallet inscribe hello.txt")
.write("hello.txt", "HELLOWORLD")
.expected_exit_code(1)
.expected_stderr("error: Bitcoin Core 24.0.0 or newer required, current version is 23.0.0\n")
.rpc_server(&rpc_server)
Expand Down

0 comments on commit 0c1a6fe

Please sign in to comment.