OSDN Git Service

annotated transaction add tx_size field
authoroysheng <oysheng@bytom.io>
Tue, 22 May 2018 06:03:21 +0000 (14:03 +0800)
committeroysheng <oysheng@bytom.io>
Tue, 22 May 2018 06:03:21 +0000 (14:03 +0800)
blockchain/query/annotated.go
wallet/annotated.go

index 4af2e23..6e94c21 100644 (file)
@@ -19,6 +19,7 @@ type AnnotatedTx struct {
        Inputs                 []*AnnotatedInput  `json:"inputs"`
        Outputs                []*AnnotatedOutput `json:"outputs"`
        StatusFail             bool               `json:"status_fail"`
+       Size                   uint64             `json:"size"`
 }
 
 //AnnotatedInput means an annotated transaction input.
@@ -55,11 +56,11 @@ type AnnotatedOutput struct {
 
 //AnnotatedAccount means an annotated account.
 type AnnotatedAccount struct {
-       ID       string           `json:"id"`
-       Alias    string           `json:"alias,omitempty"`
-       XPubs    []chainkd.XPub   `json:"xpubs"`
-       Quorum   int              `json:"quorum"`
-       KeyIndex uint64           `json:"key_index"`
+       ID       string         `json:"id"`
+       Alias    string         `json:"alias,omitempty"`
+       XPubs    []chainkd.XPub `json:"xpubs"`
+       Quorum   int            `json:"quorum"`
+       KeyIndex uint64         `json:"key_index"`
 }
 
 //AnnotatedAsset means an annotated asset.
@@ -79,6 +80,7 @@ type AssetKey struct {
        AssetDerivationPath []chainjson.HexBytes `json:"asset_derivation_path"`
 }
 
+//AnnotatedUTXO means an annotated utxo.
 type AnnotatedUTXO struct {
        Alias               string `json:"account_alias"`
        OutputID            string `json:"id"`
index 8f1e5e5..27c3bfe 100644 (file)
@@ -181,6 +181,7 @@ func (w *Wallet) buildAnnotatedTransaction(orig *types.Tx, b *types.Block, statu
                Inputs:                 make([]*query.AnnotatedInput, 0, len(orig.Inputs)),
                Outputs:                make([]*query.AnnotatedOutput, 0, len(orig.Outputs)),
                StatusFail:             statusFail,
+               Size:                   orig.SerializedSize,
        }
        for i := range orig.Inputs {
                tx.Inputs = append(tx.Inputs, w.BuildAnnotatedInput(orig, uint32(i)))