From 7f2c2cbf21241f81fa126827fd045362474bd8f3 Mon Sep 17 00:00:00 2001 From: jianyixun <317316abcd@163.com> Date: Sat, 23 Sep 2017 02:41:17 +0800 Subject: [PATCH] fix bug: hsm fix "https too many args error" --- blockchain/hsm.go | 14 +++++++++----- blockchain/reactor.go | 14 +++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/blockchain/hsm.go b/blockchain/hsm.go index 57f720e0..46a9bced 100644 --- a/blockchain/hsm.go +++ b/blockchain/hsm.go @@ -40,8 +40,8 @@ type pseudoHSMHandler struct { */ -func (a *BlockchainReactor) pseudohsmCreateKey(ctx context.Context, password string, in struct{ Alias string }) (result *pseudohsm.XPub, err error) { - return a.hsm.XCreate(password, in.Alias) +func (a *BlockchainReactor) pseudohsmCreateKey(ctx context.Context, in struct{ Alias, Password string }) (result *pseudohsm.XPub, err error) { + return a.hsm.XCreate(in.Password, in.Alias) } @@ -70,11 +70,15 @@ func (a *BlockchainReactor) pseudohsmListKeys(ctx context.Context, query request }, nil } -func (a *BlockchainReactor) pseudohsmDeleteKey(ctx context.Context, xpub chainkd.XPub, password string) error { - return a.hsm.XDelete(xpub, password) +func (a *BlockchainReactor) pseudohsmDeleteKey(ctx context.Context, x struct { + Password string + XPub chainkd.XPub `json:"xpubs"` +}) error { + return a.hsm.XDelete(x.XPub, x.Password) } -func (a *BlockchainReactor) pseudohsmSignTemplates(ctx context.Context, password string, x struct { +func (a *BlockchainReactor) pseudohsmSignTemplates(ctx context.Context, x struct { + Passwords []string Txs []*txbuilder.Template `json:"transactions"` XPubs []chainkd.XPub `json:"xpubs"` }) []interface{} { diff --git a/blockchain/reactor.go b/blockchain/reactor.go index ebe38770..12bbe7e3 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -65,14 +65,14 @@ type BlockchainReactor struct { txFeeds *txfeed.TxFeed pool *BlockPool txPool *protocol.TxPool + hsm *pseudohsm.HSM mining *cpuminer.CPUMiner mux *http.ServeMux - handler http.Handler - fastSync bool - requestsCh chan BlockRequest - timeoutsCh chan string - submitter txbuilder.Submitter - hsm *pseudohsm.HSM + handler http.Handler + fastSync bool + requestsCh chan BlockRequest + timeoutsCh chan string + submitter txbuilder.Submitter evsw types.EventSwitch } @@ -184,7 +184,7 @@ func (bcr *BlockchainReactor) BuildHander() { m.Handle("/create-access-token", jsonHandler(bcr.createAccessToken)) m.Handle("/list-access-tokens", jsonHandler(bcr.listAccessTokens)) m.Handle("/delete-access-token", jsonHandler(bcr.deleteAccessToken)) - + //hsm api m.Handle("/hsm/create-key", jsonHandler(bcr.pseudohsmCreateKey)) m.Handle("/hsm/list-keys", jsonHandler(bcr.pseudohsmListKeys)) m.Handle("/hsm/delete-key", jsonHandler(bcr.pseudohsmDeleteKey)) -- 2.11.0