Skip to content

Commit 7ed6680

Browse files
committed
Do not mutate local variable
Clippy emits: warning: field assignment outside of initializer for an instance created with Default::default() As suggested use `..Default::default()` instead of mutating.
1 parent e361cfc commit 7ed6680

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

bitcoind-tests/tests/test_cpp.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
120120
};
121121
// figure out the outpoint from the txid
122122
let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0));
123-
let mut txin = TxIn::default();
124-
txin.previous_output = outpoint;
125-
// set the sequence to a non-final number for the locktime transactions to be
126-
// processed correctly.
127-
// We waited 50 blocks, keep 49 for safety
128-
txin.sequence = Sequence::from_height(49);
123+
let txin = TxIn {
124+
previous_output: outpoint,
125+
// set the sequence to a non-final number for the locktime transactions to be
126+
// processed correctly.
127+
// We waited 50 blocks, keep 49 for safety
128+
sequence: Sequence::from_height(49),
129+
..Default::default()
130+
};
129131
psbt.unsigned_tx.input.push(txin);
130132
// Get a new script pubkey from the node so that
131133
// the node wallet tracks the receiving transaction
@@ -138,9 +140,11 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
138140
value: Amount::from_sat(99_999_000),
139141
script_pubkey: addr.script_pubkey(),
140142
});
141-
let mut input = psbt::Input::default();
142-
input.witness_utxo = Some(witness_utxo);
143-
input.witness_script = Some(desc.explicit_script().unwrap());
143+
let input = psbt::Input {
144+
witness_utxo: Some(witness_utxo),
145+
witness_script: Some(desc.explicit_script().unwrap()),
146+
..Default::default()
147+
};
144148
psbt.inputs.push(input);
145149
psbt.update_input_with_descriptor(0, &desc).unwrap();
146150
psbt.outputs.push(psbt::Output::default());

bitcoind-tests/tests/test_desc.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ pub fn test_desc_satisfy(
119119
};
120120
// figure out the outpoint from the txid
121121
let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0), derived_desc.script_pubkey());
122-
let mut txin = TxIn::default();
123-
txin.previous_output = outpoint;
124-
// set the sequence to a non-final number for the locktime transactions to be
125-
// processed correctly.
126-
// We waited 2 blocks, keep 1 for safety
127-
txin.sequence = Sequence::from_height(1);
122+
let txin = TxIn {
123+
previous_output: outpoint,
124+
// set the sequence to a non-final number for the locktime transactions to be
125+
// processed correctly.
126+
// We waited 2 blocks, keep 1 for safety
127+
sequence: Sequence::from_height(1),
128+
..Default::default()
129+
};
128130
psbt.unsigned_tx.input.push(txin);
129131
// Get a new script pubkey from the node so that
130132
// the node wallet tracks the receiving transaction

0 commit comments

Comments
 (0)