From 2aaec4f822b6286bea6d1bfeca801c0d98692bb3 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Mon, 13 Feb 2023 22:50:37 -0500 Subject: [PATCH] Create rpc client after updating index --- src/subcommand/wallet/inscribe.rs | 4 ++-- src/subcommand/wallet/send.rs | 4 ++-- tests/wallet/inscribe.rs | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 2b246543f6..a48d408d81 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -56,13 +56,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)?; diff --git a/src/subcommand/wallet/send.rs b/src/subcommand/wallet/send.rs index efe4c196df..d914764470 100644 --- a/src/subcommand/wallet/send.rs +++ b/src/subcommand/wallet/send.rs @@ -19,8 +19,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 {}", @@ -32,6 +30,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)?; diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs index 09a89ba222..65757714ba 100644 --- a/tests/wallet/inscribe.rs +++ b/tests/wallet/inscribe.rs @@ -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)