Skip to content

Commit

Permalink
change switch statement to if/else
Browse files Browse the repository at this point in the history
  • Loading branch information
Tíghearnán Carroll committed Oct 12, 2021
1 parent a8714d5 commit 3fb5ff2
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions signaturehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,15 @@ func (tx *Tx) CalcInputPreimageLegacy(inputNumber uint32, shf sighash.Flag) ([]b
}
}

switch shf & sighash.Mask { // nolint:exhaustive // no need
case sighash.None:
if shf.HasWithMask(sighash.None) {
txCopy.Outputs = txCopy.Outputs[0:0]
for i := range txCopy.Inputs {
if i != int(inputNumber) {
txCopy.Inputs[i].SequenceNumber = 0
}
}
case sighash.Single:
} else if shf.HasWithMask(sighash.Single) {
txCopy.Outputs = txCopy.Outputs[:inputNumber+1]

for i := 0; i < int(inputNumber); i++ {
txCopy.Outputs[i].Satoshis = 18446744073709551615 // -1 but underflowed
txCopy.Outputs[i].LockingScript = &bscript.Script{}
Expand All @@ -216,8 +214,6 @@ func (tx *Tx) CalcInputPreimageLegacy(inputNumber uint32, shf sighash.Flag) ([]b
txCopy.Inputs[i].SequenceNumber = 0
}
}
case sighash.Old, sighash.All:
default:
}

if shf&sighash.AnyOneCanPay != 0 {
Expand Down

0 comments on commit 3fb5ff2

Please sign in to comment.