Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flag that allows no W/U limit #1571

Merged
merged 7 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/subcommand/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl Preview {
no_backup: true,
satpoint: None,
dry_run: false,
no_limit: false,
},
)),
}
Expand Down
39 changes: 38 additions & 1 deletion src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "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.")]
casey marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) no_limit: bool,
#[clap(long, help = "Don't sign or broadcast transactions.")]
pub(crate) dry_run: bool,
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
);
Expand Down Expand Up @@ -377,6 +381,7 @@ mod tests {
reveal_address,
FeeRate::try_from(1.0).unwrap(),
FeeRate::try_from(1.0).unwrap(),
false,
)
.unwrap();

Expand Down Expand Up @@ -407,6 +412,7 @@ mod tests {
reveal_address,
FeeRate::try_from(1.0).unwrap(),
FeeRate::try_from(1.0).unwrap(),
false,
)
.unwrap();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -482,6 +489,7 @@ mod tests {
reveal_address,
FeeRate::try_from(1.0).unwrap(),
FeeRate::try_from(1.0).unwrap(),
false,
)
.is_ok())
}
Expand Down Expand Up @@ -517,6 +525,7 @@ mod tests {
reveal_address,
FeeRate::try_from(fee_rate).unwrap(),
FeeRate::try_from(fee_rate).unwrap(),
false,
)
.unwrap();

Expand Down Expand Up @@ -578,6 +587,7 @@ mod tests {
reveal_address,
FeeRate::try_from(commit_fee_rate).unwrap(),
FeeRate::try_from(fee_rate).unwrap(),
false,
)
.unwrap();

Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
}