代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package transaction
import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/protos/common"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/token"
"github.com/hyperledger/fabric/protos/utils"
"github.com/hyperledger/fabric/token/identity"
"github.com/pkg/errors"
)
func UnmarshalTokenTransaction(raw []byte) (*cb.ChannelHeader, *token.TokenTransaction, identity.PublicInfo, error) {
// the payload...
payload := &common.Payload{}
err := proto.Unmarshal(raw, payload)
if err != nil {
return nil, nil, nil, errors.Wrap(err, "error unmarshaling Payload")
}
// the creator from the signature header
sh, err := utils.GetSignatureHeader(payload.Header.SignatureHeader)
if err != nil {
return nil, nil, nil, err
}
creatorInfo := &TxCreatorInfo{public: sh.Creator}
chdr, err := utils.UnmarshalChannelHeader(payload.Header.ChannelHeader)
if err != nil {
return nil, nil, nil, err
}
// validate the payload type
if common.HeaderType(chdr.Type) != common.HeaderType_TOKEN_TRANSACTION {
return nil, nil, nil, errors.Errorf("only token transactions are supported, provided type: %d", chdr.Type)
}
ttx := &token.TokenTransaction{}
err = proto.Unmarshal(payload.Data, ttx)
if err != nil {
return nil, nil, nil, errors.Errorf("failed getting token token transaction, %s", err)
}
return chdr, ttx, creatorInfo, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。