OSDN Git Service

Add external asset ailas and definition (#278)
[bytom/bytom.git] / blockchain / query / annotated.go
1 package query
2
3 import (
4         "encoding/json"
5         "time"
6
7         "github.com/bytom/crypto/ed25519/chainkd"
8         chainjson "github.com/bytom/encoding/json"
9         "github.com/bytom/protocol/bc"
10 )
11
12 //AnnotatedTx means an annotated transaction.
13 type AnnotatedTx struct {
14         ID                     bc.Hash            `json:"id"`
15         Timestamp              time.Time          `json:"timestamp"`
16         BlockID                bc.Hash            `json:"block_id"`
17         BlockHeight            uint64             `json:"block_height"`
18         Position               uint32             `json:"position"`
19         BlockTransactionsCount uint32             `json:"block_transactions_count,omitempty"`
20         ReferenceData          *json.RawMessage   `json:"reference_data"`
21         Inputs                 []*AnnotatedInput  `json:"inputs"`
22         Outputs                []*AnnotatedOutput `json:"outputs"`
23 }
24
25 //AnnotatedInput means an annotated transaction input.
26 type AnnotatedInput struct {
27         Type            string             `json:"type"`
28         AssetID         bc.AssetID         `json:"asset_id"`
29         AssetAlias      string             `json:"asset_alias,omitempty"`
30         AssetDefinition *json.RawMessage   `json:"asset_definition"`
31         Amount          uint64             `json:"amount"`
32         IssuanceProgram chainjson.HexBytes `json:"issuance_program,omitempty"`
33         ControlProgram  chainjson.HexBytes `json:"-"`
34         SpentOutputID   *bc.Hash           `json:"spent_output_id,omitempty"`
35         AccountID       string             `json:"account_id,omitempty"`
36         AccountAlias    string             `json:"account_alias,omitempty"`
37         ReferenceData   *json.RawMessage   `json:"reference_data"`
38         Arbitrary       chainjson.HexBytes `json:"arbitrary,omitempty"`
39 }
40
41 //AnnotatedOutput means an annotated transaction output.
42 type AnnotatedOutput struct {
43         Type            string             `json:"type"`
44         OutputID        bc.Hash            `json:"id"`
45         TransactionID   *bc.Hash           `json:"transaction_id,omitempty"`
46         Position        int                `json:"position"`
47         AssetID         bc.AssetID         `json:"asset_id"`
48         AssetAlias      string             `json:"asset_alias,omitempty"`
49         AssetDefinition *json.RawMessage   `json:"asset_definition"`
50         Amount          uint64             `json:"amount"`
51         AccountID       string             `json:"account_id,omitempty"`
52         AccountAlias    string             `json:"account_alias,omitempty"`
53         ControlProgram  chainjson.HexBytes `json:"control_program"`
54         ReferenceData   *json.RawMessage   `json:"reference_data"`
55 }
56
57 //AnnotatedAccount means an annotated account.
58 type AnnotatedAccount struct {
59         ID     string           `json:"id"`
60         Alias  string           `json:"alias,omitempty"`
61         Keys   []*AccountKey    `json:"keys"`
62         Quorum int              `json:"quorum"`
63         Tags   *json.RawMessage `json:"tags"`
64 }
65
66 //AccountKey means an account key.
67 type AccountKey struct {
68         RootXPub              chainkd.XPub         `json:"root_xpub"`
69         AccountXPub           chainkd.XPub         `json:"account_xpub"`
70         AccountDerivationPath []chainjson.HexBytes `json:"account_derivation_path"`
71 }
72
73 //AnnotatedAsset means an annotated asset.
74 type AnnotatedAsset struct {
75         ID              bc.AssetID         `json:"id"`
76         Alias           string             `json:"alias,omitempty"`
77         IssuanceProgram chainjson.HexBytes `json:"issuance_program"`
78         Keys            []*AssetKey        `json:"keys"`
79         Quorum          int                `json:"quorum"`
80         Definition      *json.RawMessage   `json:"definition"`
81         Tags            *json.RawMessage   `json:"tags"`
82 }
83
84 //AssetKey means an asset key.
85 type AssetKey struct {
86         RootXPub            chainkd.XPub         `json:"root_xpub"`
87         AssetPubkey         chainjson.HexBytes   `json:"asset_pubkey"`
88         AssetDerivationPath []chainjson.HexBytes `json:"asset_derivation_path"`
89 }