From e35ae36924475e7482360440ee079a7ee4aa943b Mon Sep 17 00:00:00 2001 From: Chengcheng Zhang <943420582@qq.com> Date: Wed, 4 Sep 2019 15:47:32 +0800 Subject: [PATCH] add sign data --- blockchain/query/annotated.go | 1 + wallet/annotated.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/blockchain/query/annotated.go b/blockchain/query/annotated.go index 30d197f0..b91567c3 100644 --- a/blockchain/query/annotated.go +++ b/blockchain/query/annotated.go @@ -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. diff --git a/wallet/annotated.go b/wallet/annotated.go index 263cb6bc..fc5a5157 100644 --- a/wallet/annotated.go +++ b/wallet/annotated.go @@ -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] -- 2.11.0