diff --git a/src/subcommand/preview.rs b/src/subcommand/preview.rs index 97cc725b6b..aa3aa08413 100644 --- a/src/subcommand/preview.rs +++ b/src/subcommand/preview.rs @@ -81,6 +81,7 @@ impl Preview { no_backup: true, satpoint: None, dry_run: false, + no_limit: false, }, )), } diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 80a519c8ff..2b246543f6 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -45,6 +45,11 @@ pub(crate) struct Inscribe { pub(crate) file: PathBuf, #[clap(long, help = "Do not back up recovery key.")] pub(crate) no_backup: bool, + #[clap( + long, + help = "Do not check that transactions are equal to or below the MAX_STANDARD_TX_WEIGHT of 400,000 weight units. Transactions over this limit are currently nonstandard and will not be relayed by bitcoind in its default configuration. Do not use this flag unless you understand the implications." + )] + pub(crate) no_limit: bool, #[clap(long, help = "Don't sign or broadcast transactions.")] pub(crate) dry_run: bool, } @@ -77,6 +82,7 @@ impl Inscribe { reveal_tx_destination, self.commit_fee_rate.unwrap_or(self.fee_rate), self.fee_rate, + self.no_limit, )?; utxos.insert( @@ -140,6 +146,7 @@ impl Inscribe { destination: Address, commit_fee_rate: FeeRate, reveal_fee_rate: FeeRate, + no_limit: bool, ) -> Result<(Transaction, Transaction, TweakedKeyPair)> { let satpoint = if let Some(satpoint) = satpoint { satpoint @@ -282,7 +289,7 @@ impl Inscribe { let reveal_weight = reveal_tx.weight(); - if reveal_weight > MAX_STANDARD_TX_WEIGHT.try_into().unwrap() { + if !no_limit && reveal_weight > MAX_STANDARD_TX_WEIGHT.try_into().unwrap() { bail!( "reveal transaction weight greater than {MAX_STANDARD_TX_WEIGHT} (MAX_STANDARD_TX_WEIGHT): {reveal_weight}" ); @@ -377,6 +384,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap(); @@ -407,6 +415,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap(); @@ -441,6 +450,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap_err() .to_string(); @@ -482,6 +492,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .is_ok()) } @@ -517,6 +528,7 @@ mod tests { reveal_address, FeeRate::try_from(fee_rate).unwrap(), FeeRate::try_from(fee_rate).unwrap(), + false, ) .unwrap(); @@ -578,6 +590,7 @@ mod tests { reveal_address, FeeRate::try_from(commit_fee_rate).unwrap(), FeeRate::try_from(fee_rate).unwrap(), + false, ) .unwrap(); @@ -626,6 +639,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap_err() .to_string(); @@ -636,4 +650,30 @@ mod tests { error ); } + + #[test] + fn inscribe_with_no_max_standard_tx_weight() { + let utxos = vec![(outpoint(1), Amount::from_sat(50 * COIN_VALUE))]; + + let inscription = inscription("text/plain", [0; MAX_STANDARD_TX_WEIGHT as usize]); + let satpoint = None; + let commit_address = change(0); + let reveal_address = recipient(); + + let (_commit_tx, reveal_tx, _private_key) = Inscribe::create_inscription_transactions( + satpoint, + inscription, + BTreeMap::new(), + Network::Bitcoin, + utxos.into_iter().collect(), + [commit_address, change(1)], + reveal_address, + FeeRate::try_from(1.0).unwrap(), + FeeRate::try_from(1.0).unwrap(), + true, + ) + .unwrap(); + + assert!(reveal_tx.size() >= MAX_STANDARD_TX_WEIGHT as usize); + } } diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs index 9cc753e3d9..09a89ba222 100644 --- a/tests/wallet/inscribe.rs +++ b/tests/wallet/inscribe.rs @@ -354,3 +354,15 @@ fn inscribe_with_dry_run_flag_fees_inscrease() { assert!(total_fee_dry_run < total_fee_normal); } + +#[test] +fn inscribe_with_no_limit() { + let rpc_server = test_bitcoincore_rpc::spawn(); + create_wallet(&rpc_server); + rpc_server.mine_blocks(1); + + let four_megger = std::iter::repeat(0).take(4_000_000).collect::>(); + CommandBuilder::new("wallet inscribe --no-limit degenerate.png") + .write("degenerate.png", four_megger) + .rpc_server(&rpc_server); +}