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

Commit 4bc6967

Browse files
committed
[#1681] Protect POSTReleaseEscrow sweep when there are no inputs
1 parent 3fd0924 commit 4bc6967

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

core/completion.go

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

352-
chaincode, err := hex.DecodeString(contract.BuyerOrder.Payment.Chaincode)
353-
if err != nil {
354-
return err
355-
}
356-
mECKey, err := n.MasterPrivateKey.ECPrivKey()
357-
if err != nil {
358-
return err
359-
}
360-
vendorKey, err := wal.ChildKey(mECKey.Serialize(), chaincode, true)
361-
if err != nil {
362-
return err
363-
}
364-
redeemScript, err := hex.DecodeString(contract.BuyerOrder.Payment.RedeemScript)
365-
if err != nil {
366-
return err
367-
}
368-
_, err = wal.SweepAddress(txInputs, nil, vendorKey, &redeemScript, wallet.NORMAL)
369-
if err != nil {
370-
return err
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+
}
371373
}
372374

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

0 commit comments

Comments
 (0)