github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/blockchain/query/annotated.go (about)

     1  package query
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/bytom/bytom/crypto/ed25519/chainkd"
     7  	chainjson "github.com/bytom/bytom/encoding/json"
     8  	"github.com/bytom/bytom/protocol/bc"
     9  )
    10  
    11  //AnnotatedTx means an annotated transaction.
    12  type AnnotatedTx struct {
    13  	ID                     bc.Hash            `json:"tx_id"`
    14  	Timestamp              uint64             `json:"block_time"`
    15  	BlockID                bc.Hash            `json:"block_hash"`
    16  	BlockHeight            uint64             `json:"block_height"`
    17  	Position               uint32             `json:"block_index"`
    18  	BlockTransactionsCount uint32             `json:"block_transactions_count,omitempty"`
    19  	Inputs                 []*AnnotatedInput  `json:"inputs"`
    20  	Outputs                []*AnnotatedOutput `json:"outputs"`
    21  	Size                   uint64             `json:"size"`
    22  }
    23  
    24  //AnnotatedInput means an annotated transaction input.
    25  type AnnotatedInput struct {
    26  	Type             string               `json:"type"`
    27  	AssetID          bc.AssetID           `json:"asset_id"`
    28  	AssetAlias       string               `json:"asset_alias,omitempty"`
    29  	AssetDefinition  *json.RawMessage     `json:"asset_definition,omitempty"`
    30  	Amount           uint64               `json:"amount"`
    31  	IssuanceProgram  chainjson.HexBytes   `json:"issuance_program,omitempty"`
    32  	ControlProgram   chainjson.HexBytes   `json:"control_program,omitempty"`
    33  	Address          string               `json:"address,omitempty"`
    34  	SpentOutputID    *bc.Hash             `json:"spent_output_id,omitempty"`
    35  	AccountID        string               `json:"account_id,omitempty"`
    36  	AccountAlias     string               `json:"account_alias,omitempty"`
    37  	Arbitrary        chainjson.HexBytes   `json:"arbitrary,omitempty"`
    38  	InputID          bc.Hash              `json:"input_id"`
    39  	WitnessArguments []chainjson.HexBytes `json:"witness_arguments"`
    40  	SignData         bc.Hash              `json:"sign_data,omitempty"`
    41  
    42  	// Vote assign value only input is vote type
    43  	Vote      string   `json:"vote,omitempty"`
    44  	StateData []string `json:"state_data,omitempty"`
    45  }
    46  
    47  //AnnotatedOutput means an annotated transaction output.
    48  type AnnotatedOutput struct {
    49  	Type            string             `json:"type"`
    50  	OutputID        bc.Hash            `json:"id"`
    51  	TransactionID   *bc.Hash           `json:"transaction_id,omitempty"`
    52  	Position        int                `json:"position"`
    53  	AssetID         bc.AssetID         `json:"asset_id"`
    54  	AssetAlias      string             `json:"asset_alias,omitempty"`
    55  	AssetDefinition *json.RawMessage   `json:"asset_definition,omitempty"`
    56  	Amount          uint64             `json:"amount"`
    57  	AccountID       string             `json:"account_id,omitempty"`
    58  	AccountAlias    string             `json:"account_alias,omitempty"`
    59  	ControlProgram  chainjson.HexBytes `json:"control_program"`
    60  	Address         string             `json:"address,omitempty"`
    61  	// assign value only output is vote type
    62  	Vote string `json:"vote,omitempty"`
    63  
    64  	// assign value when output is not retirement type
    65  	StateData []string `json:"state_data,omitempty"`
    66  }
    67  
    68  //AnnotatedAccount means an annotated account.
    69  type AnnotatedAccount struct {
    70  	ID         string         `json:"id"`
    71  	Alias      string         `json:"alias,omitempty"`
    72  	XPubs      []chainkd.XPub `json:"xpubs"`
    73  	Quorum     int            `json:"quorum"`
    74  	KeyIndex   uint64         `json:"key_index"`
    75  	DeriveRule uint8          `json:"derive_rule"`
    76  }
    77  
    78  //AnnotatedAsset means an annotated asset.
    79  type AnnotatedAsset struct {
    80  	AnnotatedSigner
    81  	ID                bc.AssetID         `json:"id"`
    82  	Alias             string             `json:"alias"`
    83  	VMVersion         uint64             `json:"vm_version"`
    84  	IssuanceProgram   chainjson.HexBytes `json:"issue_program"`
    85  	RawDefinitionByte chainjson.HexBytes `json:"raw_definition_byte"`
    86  	Definition        *json.RawMessage   `json:"definition"`
    87  	LimitHeight       uint64             `json:"limit_height"`
    88  }
    89  
    90  //AnnotatedSigner means an annotated signer for asset.
    91  type AnnotatedSigner struct {
    92  	Type       string         `json:"type"`
    93  	XPubs      []chainkd.XPub `json:"xpubs"`
    94  	Quorum     int            `json:"quorum"`
    95  	KeyIndex   uint64         `json:"key_index"`
    96  	DeriveRule uint8          `json:"derive_rule"`
    97  }
    98  
    99  //AnnotatedUTXO means an annotated utxo.
   100  type AnnotatedUTXO struct {
   101  	Alias               string `json:"account_alias"`
   102  	OutputID            string `json:"id"`
   103  	AssetID             string `json:"asset_id"`
   104  	AssetAlias          string `json:"asset_alias"`
   105  	Amount              uint64 `json:"amount"`
   106  	AccountID           string `json:"account_id"`
   107  	Address             string `json:"address"`
   108  	ControlProgramIndex uint64 `json:"control_program_index"`
   109  	Program             string `json:"program"`
   110  	SourceID            string `json:"source_id"`
   111  	SourcePos           uint64 `json:"source_pos"`
   112  	ValidHeight         uint64 `json:"valid_height"`
   113  	Change              bool   `json:"change"`
   114  	DeriveRule          uint8  `json:"derive_rule"`
   115  }