Commit 79f8db5e authored by pengjun's avatar pengjun

add cert action

parent ff466f76
......@@ -61,15 +61,27 @@ func (c *TxController) signTx(tx *types.Transaction, priv crypto.PrivKey) {
priv, err := cr.PrivKeyFromBytes(user.Key)
if err != nil {
txlog.Error(fmt.Sprintf("get private key failed, error:%s", err))
return
}
var action int32
switch c.Ctx.Input.Header("action") {
case "new":
action = types.CertActionNew
case "update":
action = types.CertActionUpdate
default:
action = types.CertActionNormal
}
transfer := &types.CertAction{Value: nil, Ty: action}
tx.Payload = types.Encode(transfer)
tx.To = address.ExecAddress(string(tx.Execer))
tx.Sign(int32(SignType), priv)
certSign := crypto.CertSignature{}
certSign.Signature = append(certSign.Signature, tx.Signature.Signature...)
certSign.Cert = append(certSign.Cert, user.Cert...)
tx.Signature.Signature, _ = asn1.Marshal(certSign)
fmt.Printf("cert:%x sig:%x\n", certSign.Cert, tx.Signature.Signature)
return
}
......
{"C:\\Users\\jpeng\\go\\src\\gitlab.33.cn\\lihailei\\chain33_sdk\\src\\controllers":1531984871424137700,"D:\\Repository\\src\\gitlab.33.cn\\lihailei\\chain33_sdk\\src\\controllers":1527576308546695900}
\ No newline at end of file
{"C:\\Users\\jpeng\\go\\src\\gitlab.33.cn\\lihailei\\chain33_sdk\\src\\controllers":1532074944699638900,"D:\\Repository\\src\\gitlab.33.cn\\lihailei\\chain33_sdk\\src\\controllers":1527576308546695900}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment