Skip to content

Commit 23e6f4b

Browse files
committed
f cache .txid()
1 parent 4a81c1f commit 23e6f4b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lightning/src/ln/interactivetxs.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,15 @@ impl NegotiationContext {
138138
}
139139

140140
let transaction = msg.prevtx.as_transaction();
141+
let txid = transaction.txid();
141142

142143
if let Some(tx_out) = transaction.output.get(msg.prevtx_out as usize) {
143144
if !tx_out.script_pubkey.is_witness_program() {
144145
// The receiving node:
145146
// - MUST fail the negotiation if:
146147
// - the `scriptPubKey` is not a witness program
147148
return Err(AbortReason::PrevTxOutInvalid);
148-
} else if !self
149-
.prevtx_outpoints
150-
.insert(OutPoint { txid: transaction.txid(), vout: msg.prevtx_out })
151-
{
149+
} else if !self.prevtx_outpoints.insert(OutPoint { txid, vout: msg.prevtx_out }) {
152150
// The receiving node:
153151
// - MUST fail the negotiation if:
154152
// - the `prevtx` and `prevtx_vout` are identical to a previously added
@@ -173,7 +171,7 @@ impl NegotiationContext {
173171
// - the `serial_id` is already included in the transaction
174172
return Err(AbortReason::DuplicateSerialId);
175173
}
176-
let prev_outpoint = OutPoint { txid: transaction.txid(), vout: msg.prevtx_out };
174+
let prev_outpoint = OutPoint { txid, vout: msg.prevtx_out };
177175
self.inputs.insert(
178176
msg.serial_id,
179177
TxInputWithPrevOutput {

0 commit comments

Comments
 (0)