diff --git a/src/options.rs b/src/options.rs index 32c3a1614d..02d51856b0 100644 --- a/src/options.rs +++ b/src/options.rs @@ -135,35 +135,15 @@ impl Options { Ok(client) } - pub(crate) fn bitcoin_rpc_client_mainnet_forbidden(&self, command: &str) -> Result { - let client = self.bitcoin_rpc_client()?; - - if self.chain() == Chain::Mainnet { - bail!("`{command}` is unstable and not yet supported on mainnet."); - } - Ok(client) - } - pub(crate) fn bitcoin_rpc_client_for_wallet_command(&self, command: &str) -> Result { let client = self.bitcoin_rpc_client()?; - if self.chain() == Chain::Mainnet { - let wallet_info = client.get_wallet_info()?; - - if !(wallet_info.wallet_name == "ord" || wallet_info.wallet_name.starts_with("ord-")) { - bail!("`{command}` may only be used on mainnet with a wallet named `ord` or whose name starts with `ord-`"); - } - - let balances = client.get_balances()?; + let wallet_info = client.get_wallet_info()?; - let total = balances.mine.trusted + balances.mine.untrusted_pending + balances.mine.immature; - - if total > Amount::from_sat(1_000_000) { - bail!( - "`{command}` may not be used on mainnet with wallets containing more than 1,000,000 sats" - ); - } + if !(wallet_info.wallet_name == "ord" || wallet_info.wallet_name.starts_with("ord-")) { + bail!("`{command}` may only be used on mainnet with a wallet named `ord` or whose name starts with `ord-`"); } + Ok(client) } } diff --git a/src/subcommand/wallet/create.rs b/src/subcommand/wallet/create.rs index 323997e048..1db103ed63 100644 --- a/src/subcommand/wallet/create.rs +++ b/src/subcommand/wallet/create.rs @@ -2,7 +2,7 @@ use super::*; pub(crate) fn run(options: Options) -> Result { options - .bitcoin_rpc_client_mainnet_forbidden("ord wallet create")? + .bitcoin_rpc_client()? .create_wallet("ord", None, None, None, None)?; Ok(()) } diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 58d6531997..ccd8de4b40 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -39,7 +39,7 @@ pub(crate) struct Inscribe { impl Inscribe { pub(crate) fn run(self, options: Options) -> Result { - let client = options.bitcoin_rpc_client_mainnet_forbidden("ord wallet inscribe")?; + let client = options.bitcoin_rpc_client_for_wallet_command("ord wallet inscribe")?; let bitcoin_version = client.version()?; if bitcoin_version < MIN_BITCOIN_VERSION { diff --git a/tests/wallet.rs b/tests/wallet.rs index 3f7007944e..4a8f6c6dda 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -226,20 +226,6 @@ fn send_on_mainnnet_works_with_wallet_whose_name_starts_with_ord() { assert_eq!(format!("{}\n", txid), stdout); } -#[test] -fn send_on_mainnnet_refuses_to_work_with_wallet_with_high_balance() { - let rpc_server = test_bitcoincore_rpc::builder().build(); - let txid = rpc_server.mine_blocks_with_subsidy(1, 1_000_001)[0].txdata[0].txid(); - - CommandBuilder::new(format!("wallet send ord1qcqgs2pps4u4yedfyl5pysdjjncs8et5u8gcumw {txid}:0:0")) - .rpc_server(&rpc_server) - .expected_stderr( - "error: `ord wallet send` may not be used on mainnet with wallets containing more than 1,000,000 sats\n", - ) - .expected_exit_code(1) - .run(); -} - #[test] fn inscribe_fails_if_bitcoin_core_is_too_old() { let rpc_server = test_bitcoincore_rpc::builder() @@ -279,18 +265,6 @@ fn inscribe_no_backup() { assert_eq!(rpc_server.descriptors(), 0); } -#[test] -fn inscribe_forbidden_on_mainnet() { - let rpc_server = test_bitcoincore_rpc::builder().build(); - let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid(); - - CommandBuilder::new(format!("wallet inscribe --satpoint {txid}:0:0 hello.txt")) - .rpc_server(&rpc_server) - .expected_exit_code(1) - .expected_stderr("error: `ord wallet inscribe` is unstable and not yet supported on mainnet.\n") - .run(); -} - #[test] fn inscribe() { let rpc_server = test_bitcoincore_rpc::builder()