From d831b8ab1b1a794153b482a61b18c664378002c6 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 8 Feb 2023 00:55:35 +0100 Subject: [PATCH 1/6] flag that allows no W/U limit --- src/subcommand/preview.rs | 1 + src/subcommand/wallet/inscribe.rs | 39 ++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) 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..a6e678a696 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -45,6 +45,8 @@ 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 = "Suspend W/U limit.")] + pub(crate) no_limit: bool, #[clap(long, help = "Don't sign or broadcast transactions.")] pub(crate) dry_run: bool, } @@ -77,6 +79,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 +143,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 +286,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 +381,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap(); @@ -407,6 +412,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap(); @@ -441,6 +447,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap_err() .to_string(); @@ -482,6 +489,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .is_ok()) } @@ -517,6 +525,7 @@ mod tests { reveal_address, FeeRate::try_from(fee_rate).unwrap(), FeeRate::try_from(fee_rate).unwrap(), + false, ) .unwrap(); @@ -578,6 +587,7 @@ mod tests { reveal_address, FeeRate::try_from(commit_fee_rate).unwrap(), FeeRate::try_from(fee_rate).unwrap(), + false, ) .unwrap(); @@ -626,6 +636,7 @@ mod tests { reveal_address, FeeRate::try_from(1.0).unwrap(), FeeRate::try_from(1.0).unwrap(), + false, ) .unwrap_err() .to_string(); @@ -636,4 +647,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); + } } From 25fd85f1009cdbff57f06618b58cc5d278bc44fc Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 7 Feb 2023 16:01:45 -0800 Subject: [PATCH 2/6] Update src/subcommand/wallet/inscribe.rs --- src/subcommand/wallet/inscribe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index a6e678a696..8b931dc55d 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -45,7 +45,7 @@ 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 = "Suspend W/U limit.")] + #[clap(long, help = "Do not check MAX_STANDARD_TX_WEIGHT. Transactions over the 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 of this.")] pub(crate) no_limit: bool, #[clap(long, help = "Don't sign or broadcast transactions.")] pub(crate) dry_run: bool, From 096d3cb3300cddaa0cf225a55b3ccfbd1a256672 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 7 Feb 2023 16:03:55 -0800 Subject: [PATCH 3/6] Update src/subcommand/wallet/inscribe.rs --- src/subcommand/wallet/inscribe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 8b931dc55d..10e55768f8 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -45,7 +45,7 @@ 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 MAX_STANDARD_TX_WEIGHT. Transactions over the 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 of this.")] + #[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, From f1a820f3b3afaf72c48d79569a54fbaafcafc548 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 8 Feb 2023 01:08:53 +0100 Subject: [PATCH 4/6] quick fix --- tests/wallet/inscribe.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs index 9cc753e3d9..03195181c1 100644 --- a/tests/wallet/inscribe.rs +++ b/tests/wallet/inscribe.rs @@ -354,3 +354,14 @@ 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); + + CommandBuilder::new("wallet inscribe --no-limit degenerate.png") + .write("degenerate.png", [1; 1_000_000]) + .rpc_server(&rpc_server); +} From 6f02ae4750bc5760d3a08632b0923f2756e61490 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 8 Feb 2023 01:16:44 +0100 Subject: [PATCH 5/6] quick fix --- src/subcommand/wallet/inscribe.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 10e55768f8..2b246543f6 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -45,7 +45,10 @@ 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.")] + #[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, From 6d6fae08c29496bb39ef13f2c7285f6995eb8bb4 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 8 Feb 2023 01:27:09 +0100 Subject: [PATCH 6/6] four megger --- tests/wallet/inscribe.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs index 03195181c1..09a89ba222 100644 --- a/tests/wallet/inscribe.rs +++ b/tests/wallet/inscribe.rs @@ -361,7 +361,8 @@ fn inscribe_with_no_limit() { 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", [1; 1_000_000]) + .write("degenerate.png", four_megger) .rpc_server(&rpc_server); }