Skip to content

Commit f10b69e

Browse files
Merge branch 'master' into output_recursive
2 parents 3694157 + 5749363 commit f10b69e

File tree

9 files changed

+71
-67
lines changed

9 files changed

+71
-67
lines changed

crates/mockcore/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub struct FundRawTransactionResult {
198198
pub change_position: i32,
199199
}
200200

201-
impl<'a> Default for TransactionTemplate<'a> {
201+
impl Default for TransactionTemplate<'_> {
202202
fn default() -> Self {
203203
Self {
204204
fee: 0,

src/index/updater.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(crate) struct Updater<'index> {
4040
pub(super) sat_ranges_since_flush: u64,
4141
}
4242

43-
impl<'index> Updater<'index> {
43+
impl Updater<'_> {
4444
pub(crate) fn update_index(&mut self, mut wtx: WriteTransaction) -> Result {
4545
let start = Instant::now();
4646
let starting_height = u32::try_from(self.index.client.get_block_count()?).unwrap() + 1;

src/index/updater/inscription_updater.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) struct InscriptionUpdater<'a, 'tx> {
5858
pub(super) unbound_inscriptions: u64,
5959
}
6060

61-
impl<'a, 'tx> InscriptionUpdater<'a, 'tx> {
61+
impl InscriptionUpdater<'_, '_> {
6262
pub(super) fn index_inscriptions(
6363
&mut self,
6464
tx: &Transaction,

src/index/updater/rune_updater.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(super) struct RuneUpdater<'a, 'tx, 'client> {
1717
pub(super) transaction_id_to_rune: &'a mut Table<'tx, &'static TxidValue, u128>,
1818
}
1919

20-
impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> {
20+
impl RuneUpdater<'_, '_, '_> {
2121
pub(super) fn index_runes(&mut self, tx_index: u32, tx: &Transaction, txid: Txid) -> Result<()> {
2222
let artifact = Runestone::decipher(tx);
2323

src/index/utxo_entry.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ impl UtxoEntry {
9191
}
9292

9393
impl redb::Value for &UtxoEntry {
94-
type SelfType<'a> = &'a UtxoEntry where Self: 'a;
95-
type AsBytes<'a> = &'a [u8] where Self: 'a;
94+
type SelfType<'a>
95+
= &'a UtxoEntry
96+
where
97+
Self: 'a;
98+
99+
type AsBytes<'a>
100+
= &'a [u8]
101+
where
102+
Self: 'a;
96103

97104
fn fixed_width() -> Option<usize> {
98105
None

src/subcommand/wallet/burn.rs

+14-28
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ pub struct Burn {
2828
you understand the implications."
2929
)]
3030
no_limit: bool,
31-
#[arg(
32-
long,
33-
help = "Target <AMOUNT> postage with sent inscriptions. [default: 10000 sat]",
34-
value_name = "AMOUNT"
35-
)]
36-
postage: Option<Amount>,
3731
inscription: InscriptionId,
3832
}
3933

@@ -47,21 +41,10 @@ impl Burn {
4741

4842
let metadata = WalletCommand::parse_metadata(self.cbor_metadata, self.json_metadata)?;
4943

50-
let Some(value) = inscription_info.value else {
51-
bail!("Cannot burn unbound inscription");
52-
};
53-
54-
let value = Amount::from_sat(value);
55-
56-
ensure! {
57-
value <= TARGET_POSTAGE,
58-
"Cannot burn inscription contained in UTXO exceeding {TARGET_POSTAGE}",
59-
}
60-
61-
ensure! {
62-
self.postage.unwrap_or_default() <= TARGET_POSTAGE,
63-
"Postage may not exceed {TARGET_POSTAGE}",
64-
}
44+
ensure!(
45+
inscription_info.value.is_some(),
46+
"Cannot burn unbound inscription"
47+
);
6548

6649
let mut builder = script::Builder::new().push_opcode(opcodes::all::OP_RETURN);
6750

@@ -96,12 +79,14 @@ impl Burn {
9679
MAX_STANDARD_OP_RETURN_SIZE,
9780
);
9881

82+
let burn_amount = Amount::from_sat(1);
83+
9984
let unsigned_transaction = Self::create_unsigned_burn_transaction(
10085
&wallet,
10186
inscription_info.satpoint,
102-
self.postage,
10387
self.fee_rate,
10488
script_pubkey,
89+
burn_amount,
10590
)?;
10691

10792
let base_size = unsigned_transaction.base_size();
@@ -110,8 +95,11 @@ impl Burn {
11095
"transaction base size less than minimum standard tx nonwitness size: {base_size} < 65",
11196
);
11297

113-
let (txid, psbt, fee) =
114-
wallet.sign_and_broadcast_transaction(unsigned_transaction, self.dry_run, Some(value))?;
98+
let (txid, psbt, fee) = wallet.sign_and_broadcast_transaction(
99+
unsigned_transaction,
100+
self.dry_run,
101+
Some(burn_amount),
102+
)?;
115103

116104
Ok(Some(Box::new(send::Output {
117105
txid,
@@ -124,9 +112,9 @@ impl Burn {
124112
fn create_unsigned_burn_transaction(
125113
wallet: &Wallet,
126114
satpoint: SatPoint,
127-
postage: Option<Amount>,
128115
fee_rate: FeeRate,
129116
script_pubkey: ScriptBuf,
117+
burn_amount: Amount,
130118
) -> Result<Transaction> {
131119
let runic_outputs = wallet.get_runic_outputs()?;
132120

@@ -137,8 +125,6 @@ impl Burn {
137125

138126
let change = [wallet.get_change_address()?, wallet.get_change_address()?];
139127

140-
let postage = postage.map(Target::ExactPostage).unwrap_or(Target::Postage);
141-
142128
Ok(
143129
TransactionBuilder::new(
144130
satpoint,
@@ -149,7 +135,7 @@ impl Burn {
149135
script_pubkey,
150136
change,
151137
fee_rate,
152-
postage,
138+
Target::ExactPostage(burn_amount),
153139
wallet.chain().network(),
154140
)
155141
.build_transaction()?,

src/templates/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
pub(crate) struct MetadataHtml<'a>(pub &'a Value);
44

5-
impl<'a> Display for MetadataHtml<'a> {
5+
impl Display for MetadataHtml<'_> {
66
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
77
match self.0 {
88
Value::Array(x) => {

tests/server.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fn run() {
3232
}
3333

3434
child.kill().unwrap();
35+
child.wait().unwrap();
3536
}
3637

3738
#[test]
@@ -741,6 +742,7 @@ fn run_no_sync() {
741742
}
742743

743744
child.kill().unwrap();
745+
child.wait().unwrap();
744746

745747
let builder = CommandBuilder::new(format!(
746748
"server --no-sync --address 127.0.0.1 --http-port {port}",
@@ -770,6 +772,7 @@ fn run_no_sync() {
770772
}
771773

772774
child.kill().unwrap();
775+
child.wait().unwrap();
773776
}
774777

775778
#[test]
@@ -814,6 +817,7 @@ fn authentication() {
814817
assert_eq!(response.status(), 200);
815818

816819
child.kill().unwrap();
820+
child.wait().unwrap();
817821
}
818822

819823
#[cfg(unix)]

tests/wallet/burn.rs

+39-32
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn inscriptions_can_be_burned() {
3333
<span title=burned>🔥</span>
3434
</dd>
3535
<dt>value</dt>
36-
<dd>9918</dd>
36+
<dd>1</dd>
3737
.*
3838
<dt>content length</dt>
3939
<dd>3 bytes</dd>
@@ -116,7 +116,7 @@ fn runic_outputs_are_protected() {
116116
}
117117

118118
#[test]
119-
fn cannot_burn_inscriptions_on_large_utxos() {
119+
fn burns_only_one_sat() {
120120
let core = mockcore::spawn();
121121

122122
let ord = TestServer::spawn_with_server_args(&core, &[], &[]);
@@ -125,14 +125,45 @@ fn cannot_burn_inscriptions_on_large_utxos() {
125125

126126
core.mine_blocks(1);
127127

128-
let (inscription, _) = inscribe_with_postage(&core, &ord, Some(10_001));
128+
assert_eq!(
129+
CommandBuilder::new("wallet balance")
130+
.core(&core)
131+
.ord(&ord)
132+
.run_and_deserialize_output::<Balance>(),
133+
Balance {
134+
cardinal: 50 * COIN_VALUE,
135+
ordinal: 0,
136+
runic: None,
137+
runes: None,
138+
total: 50 * COIN_VALUE,
139+
}
140+
);
141+
142+
let (inscription, _) = inscribe_with_postage(&core, &ord, Some(100_000));
129143

130144
CommandBuilder::new(format!("wallet burn --fee-rate 1 {inscription}",))
131145
.core(&core)
132146
.ord(&ord)
133-
.expected_stderr("error: Cannot burn inscription contained in UTXO exceeding 0.00010000 BTC\n")
134-
.expected_exit_code(1)
135-
.run_and_extract_stdout();
147+
.run_and_deserialize_output::<Send>();
148+
149+
core.mine_blocks(1);
150+
151+
// 4 block rewards - 1 burned sat
152+
let expected_balance = 4 * 50 * COIN_VALUE - 1;
153+
154+
assert_eq!(
155+
CommandBuilder::new("wallet balance")
156+
.core(&core)
157+
.ord(&ord)
158+
.run_and_deserialize_output::<Balance>(),
159+
Balance {
160+
cardinal: expected_balance,
161+
ordinal: 0,
162+
runic: None,
163+
runes: None,
164+
total: expected_balance,
165+
}
166+
);
136167
}
137168

138169
#[test]
@@ -191,30 +222,6 @@ fn cannot_burn_inscription_sharing_utxo_with_another_inscription() {
191222
.run_and_extract_stdout();
192223
}
193224

194-
#[test]
195-
fn cannot_burn_with_excess_postage() {
196-
let core = mockcore::spawn();
197-
198-
let ord = TestServer::spawn_with_server_args(&core, &[], &[]);
199-
200-
create_wallet(&core, &ord);
201-
202-
core.mine_blocks(1);
203-
204-
let (inscription, _) = inscribe(&core, &ord);
205-
206-
core.mine_blocks(1);
207-
208-
CommandBuilder::new(format!(
209-
"wallet burn --fee-rate 1 {inscription} --postage 10001sat",
210-
))
211-
.core(&core)
212-
.ord(&ord)
213-
.expected_stderr("error: Postage may not exceed 0.00010000 BTC\n")
214-
.expected_exit_code(1)
215-
.run_and_extract_stdout();
216-
}
217-
218225
#[test]
219226
fn json_metadata_can_be_included_when_burning() {
220227
let core = mockcore::spawn();
@@ -258,7 +265,7 @@ fn json_metadata_can_be_included_when_burning() {
258265
fee: 138,
259266
id: inscription,
260267
output: Some(TxOut {
261-
value: Amount::from_sat(9907),
268+
value: Amount::from_sat(1),
262269
script_pubkey,
263270
}),
264271
height: 3,
@@ -327,7 +334,7 @@ fn cbor_metadata_can_be_included_when_burning() {
327334
fee: 138,
328335
id: inscription,
329336
output: Some(TxOut {
330-
value: Amount::from_sat(9907),
337+
value: Amount::from_sat(1),
331338
script_pubkey,
332339
}),
333340
height: 3,

0 commit comments

Comments
 (0)