OSDN Git Service

add SignComplete
authorChengcheng Zhang <943420582@qq.com>
Tue, 10 Sep 2019 13:49:02 +0000 (21:49 +0800)
committerChengcheng Zhang <943420582@qq.com>
Tue, 10 Sep 2019 13:49:02 +0000 (21:49 +0800)
swap/htlc.go
swap/trade_offer.go

index 6578e2d..cb867ea 100644 (file)
@@ -328,6 +328,10 @@ func signUnlockHTLCContractTransaction(account AccountInfo, preimage, recipientS
                return "", err
        }
 
+       if !res.SignComplete {
+               return "", errFailedSignTx
+       }
+
        return res.Tx.RawTransaction, nil
 }
 
index a36eaca..d611984 100644 (file)
@@ -14,6 +14,7 @@ var (
        errMarshal                   = errors.New("Failed to marshal")
        errListUnspentOutputs        = errors.New("Failed to list unspent outputs")
        errTradeOffParametersInvalid = errors.New("Trade off parameters invalid")
+       errFailedSignTx              = errors.New("Failed to sign transaction")
 )
 
 type compileLockContractResp struct {
@@ -109,7 +110,8 @@ type Transaction struct {
 }
 
 type signTxResp struct {
-       Tx Transaction `json:"transaction"`
+       Tx           Transaction `json:"transaction"`
+       SignComplete bool        `json:"sign_complete"`
 }
 
 // signTransaction sign built contract transaction.
@@ -124,6 +126,10 @@ func signTransaction(password string, transaction interface{}) (string, error) {
                return "", err
        }
 
+       if !res.SignComplete {
+               return "", errFailedSignTx
+       }
+
        return res.Tx.RawTransaction, nil
 }