Skip to content

Commit

Permalink
Fix using of input prevout (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
altafan authored Dec 28, 2023
1 parent e420485 commit d677ab6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions psetv2/blinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ func (i OwnedInput) validate(p *Pset) error {
if int(i.Index) > int(p.Global.InputCount)-1 {
return ErrInputIndexOutOfRange
}
prevOut := p.Inputs[i.Index].GetUtxo()
if !prevOut.IsConfidential() {
prevout := p.Inputs[i.Index].GetUtxo()
if prevout == nil {
return fmt.Errorf("missing input prevout")
}
if !prevout.IsConfidential() {
return nil
}
if i.Value == 0 {
Expand Down Expand Up @@ -486,7 +489,11 @@ func (b *Blinder) validateBlindingArgs(
asset = buf[1:]
assetBlinder = ownedIn.AssetBlinder
} else {
asset = in.GetUtxo().Asset
prevout := in.GetUtxo()
if prevout == nil {
return fmt.Errorf("missing input prevout")
}
asset = prevout.Asset
assetBlinder = zeroBlinder
}
inAssets = append(inAssets, asset)
Expand Down
3 changes: 3 additions & 0 deletions psetv2/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ func (i *Input) GetIssuanceInflationKeysHash() []byte {
}

func (i *Input) GetUtxo() *transaction.TxOutput {
if i.WitnessUtxo == nil && i.NonWitnessUtxo == nil {
return nil
}
utxo := i.WitnessUtxo
if utxo == nil {
utxo = i.NonWitnessUtxo.Outputs[i.PreviousTxIndex]
Expand Down

0 comments on commit d677ab6

Please sign in to comment.