"encoding/json"
"github.com/bytom/blockchain/query"
- "github.com/bytom/blockchain/signers"
chainjson "github.com/bytom/encoding/json"
"github.com/bytom/protocol/vm/vmutil"
)
annotatedAsset.LimitHeight, _ = vmutil.GetIssuanceProgramRestrictHeight(a.IssuanceProgram)
if a.Signer != nil {
- path := signers.GetBip0032Path(a.Signer, signers.AssetKeySpace)
- var jsonPath []chainjson.HexBytes
- for _, p := range path {
- jsonPath = append(jsonPath, p)
+ annotatedAsset.AnnotatedSigner = query.AnnotatedSigner{
+ Type: a.Signer.Type,
+ XPubs: a.Signer.XPubs,
+ Quorum: a.Signer.Quorum,
+ KeyIndex: a.Signer.KeyIndex,
+ DeriveRule: a.Signer.DeriveRule,
}
- for _, xpub := range a.Signer.XPubs {
- derived := xpub.Derive(path)
- annotatedAsset.Keys = append(annotatedAsset.Keys, &query.AssetKey{
- RootXPub: xpub,
- AssetPubkey: derived[:],
- AssetDerivationPath: jsonPath,
- })
- }
- annotatedAsset.Quorum = a.Signer.Quorum
}
return annotatedAsset, nil
}
//AnnotatedAsset means an annotated asset.
type AnnotatedAsset struct {
+ AnnotatedSigner
ID bc.AssetID `json:"id"`
Alias string `json:"alias"`
VMVersion uint64 `json:"vm_version"`
IssuanceProgram chainjson.HexBytes `json:"issue_program"`
- Keys []*AssetKey `json:"keys"`
- Quorum int `json:"quorum"`
RawDefinitionByte chainjson.HexBytes `json:"raw_definition_byte"`
Definition *json.RawMessage `json:"definition"`
LimitHeight int64 `json:"limit_height"`
}
-//AssetKey means an asset key.
-type AssetKey struct {
- RootXPub chainkd.XPub `json:"root_xpub"`
- AssetPubkey chainjson.HexBytes `json:"asset_pubkey"`
- AssetDerivationPath []chainjson.HexBytes `json:"asset_derivation_path"`
+//AnnotatedSigner means an annotated signer for asset.
+type AnnotatedSigner struct {
+ Type string `json:"type"`
+ XPubs []chainkd.XPub `json:"xpubs"`
+ Quorum int `json:"quorum"`
+ KeyIndex uint64 `json:"key_index"`
+ DeriveRule uint8 `json:"derive_rule"`
}
//AnnotatedUTXO means an annotated utxo.