Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 6804ab0

Browse files
committed
Error on no inputs available
1 parent 4bc6967 commit 6804ab0

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

core/completion.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -349,27 +349,29 @@ func (n *OpenBazaarNode) ReleaseFundsAfterTimeout(contract *pb.RicardianContract
349349
}
350350
}
351351

352-
if len(txInputs) != 0 {
353-
chaincode, err := hex.DecodeString(contract.BuyerOrder.Payment.Chaincode)
354-
if err != nil {
355-
return err
356-
}
357-
mECKey, err := n.MasterPrivateKey.ECPrivKey()
358-
if err != nil {
359-
return err
360-
}
361-
vendorKey, err := wal.ChildKey(mECKey.Serialize(), chaincode, true)
362-
if err != nil {
363-
return err
364-
}
365-
redeemScript, err := hex.DecodeString(contract.BuyerOrder.Payment.RedeemScript)
366-
if err != nil {
367-
return err
368-
}
369-
_, err = wal.SweepAddress(txInputs, nil, vendorKey, &redeemScript, wallet.NORMAL)
370-
if err != nil {
371-
return err
372-
}
352+
if len(txInputs) == 0 {
353+
return errors.New("there are no inputs available for this transaction")
354+
}
355+
356+
chaincode, err := hex.DecodeString(contract.BuyerOrder.Payment.Chaincode)
357+
if err != nil {
358+
return err
359+
}
360+
mECKey, err := n.MasterPrivateKey.ECPrivKey()
361+
if err != nil {
362+
return err
363+
}
364+
vendorKey, err := wal.ChildKey(mECKey.Serialize(), chaincode, true)
365+
if err != nil {
366+
return err
367+
}
368+
redeemScript, err := hex.DecodeString(contract.BuyerOrder.Payment.RedeemScript)
369+
if err != nil {
370+
return err
371+
}
372+
_, err = wal.SweepAddress(txInputs, nil, vendorKey, &redeemScript, wallet.NORMAL)
373+
if err != nil {
374+
return err
373375
}
374376

375377
orderID, err := n.CalcOrderID(contract.BuyerOrder)

0 commit comments

Comments
 (0)