OSDN Git Service

add sign data add-sign-data
authorChengcheng Zhang <943420582@qq.com>
Wed, 4 Sep 2019 07:47:32 +0000 (15:47 +0800)
committerChengcheng Zhang <943420582@qq.com>
Wed, 4 Sep 2019 07:47:32 +0000 (15:47 +0800)
blockchain/query/annotated.go
wallet/annotated.go

index 30d197f..b91567c 100644 (file)
@@ -38,6 +38,7 @@ type AnnotatedInput struct {
        Arbitrary        chainjson.HexBytes   `json:"arbitrary,omitempty"`
        InputID          bc.Hash              `json:"input_id"`
        WitnessArguments []chainjson.HexBytes `json:"witness_arguments"`
+       SignData         bc.Hash              `json:"sign_data,omitempty"`
 }
 
 //AnnotatedOutput means an annotated transaction output.
index 263cb6b..fc5a515 100644 (file)
@@ -14,10 +14,10 @@ import (
        "github.com/bytom/consensus"
        "github.com/bytom/consensus/segwit"
        "github.com/bytom/crypto/sha3pool"
+       dbm "github.com/bytom/database/leveldb"
        "github.com/bytom/protocol/bc"
        "github.com/bytom/protocol/bc/types"
        "github.com/bytom/protocol/vm/vmutil"
-       dbm "github.com/bytom/database/leveldb"
 )
 
 // annotateTxs adds asset data to transactions
@@ -168,7 +168,6 @@ func (w *Wallet) buildAnnotatedTransaction(orig *types.Tx, b *types.Block, statu
        return tx
 }
 
-// BuildAnnotatedInput build the annotated input.
 func (w *Wallet) BuildAnnotatedInput(tx *types.Tx, i uint32) *query.AnnotatedInput {
        orig := tx.Inputs[i]
        in := &query.AnnotatedInput{
@@ -177,6 +176,7 @@ func (w *Wallet) BuildAnnotatedInput(tx *types.Tx, i uint32) *query.AnnotatedInp
        if orig.InputType() != types.CoinbaseInputType {
                in.AssetID = orig.AssetID()
                in.Amount = orig.Amount()
+               in.SignData = tx.SigHash(i)
        }
 
        id := tx.Tx.InputIDs[i]