Skip to content

Commit f1d90cc

Browse files
authored
Merge pull request #5123 from stacks-network/chore/debug-logs
fix: key register op must have a change output
2 parents dd2404a + 5780503 commit f1d90cc

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

stackslib/src/chainstate/burn/operations/leader_key_register.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,33 +135,23 @@ impl LeaderKeyRegisterOp {
135135
let num_inputs = tx.num_signers();
136136
let num_outputs = tx.num_recipients();
137137

138-
if num_inputs == 0 {
139-
test_debug!(
138+
if num_inputs == 0 || num_outputs < 1 {
139+
debug!(
140140
"Invalid tx: inputs: {}, outputs: {}",
141-
num_inputs,
142-
num_outputs,
143-
);
144-
return Err(op_error::InvalidInput);
145-
}
146-
147-
if num_outputs < 1 {
148-
test_debug!(
149-
"Invalid tx: inputs: {}, outputs: {}",
150-
num_inputs,
151-
num_outputs
141+
num_inputs, num_outputs,
152142
);
153143
return Err(op_error::InvalidInput);
154144
}
155145

156146
if tx.opcode() != Opcodes::LeaderKeyRegister as u8 {
157-
test_debug!("Invalid tx: invalid opcode {}", tx.opcode());
147+
debug!("Invalid tx: invalid opcode {}", tx.opcode());
158148
return Err(op_error::InvalidInput);
159149
}
160150

161151
let data = match LeaderKeyRegisterOp::parse_data(&tx.data()) {
162152
Some(data) => data,
163153
None => {
164-
test_debug!("Invalid tx data");
154+
debug!("Invalid tx data");
165155
return Err(op_error::ParseError);
166156
}
167157
};

testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ impl BitcoinRegtestController {
889889
fee_rate,
890890
&mut utxos,
891891
signer,
892-
false,
892+
true, // key register op requires change output to exist
893893
)?;
894894

895895
increment_btc_ops_sent_counter();
@@ -1466,7 +1466,7 @@ impl BitcoinRegtestController {
14661466
fee_rate,
14671467
&mut utxos,
14681468
signer,
1469-
true, // only block commit op requires change output to exist
1469+
true, // block commit op requires change output to exist
14701470
)?;
14711471

14721472
let serialized_tx = SerializedTx::new(tx.clone());

0 commit comments

Comments
 (0)