mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-22 17:31:34 +00:00
sign_tx to sign any transaction
This commit is contained in:
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
blk "github.com/tendermint/tendermint/block"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
)
|
||||
|
||||
@ -60,37 +59,3 @@ func ListAccountsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
Accounts []*account.Account
|
||||
}{blockHeight, accounts})
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
func SignSendTxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
sendTxStr := GetParam(r, "sendTx")
|
||||
privAccountsStr := GetParam(r, "privAccounts")
|
||||
|
||||
var err error
|
||||
sendTx := binary.ReadJSON(&blk.SendTx{}, []byte(sendTxStr), &err).(*blk.SendTx)
|
||||
if err != nil {
|
||||
WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid sendTx: %v", err))
|
||||
return
|
||||
}
|
||||
privAccounts := binary.ReadJSON([]*account.PrivAccount{}, []byte(privAccountsStr), &err).([]*account.PrivAccount)
|
||||
if err != nil {
|
||||
WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid privAccounts: %v", err))
|
||||
return
|
||||
}
|
||||
for i, privAccount := range privAccounts {
|
||||
if privAccount == nil || privAccount.PrivKey == nil {
|
||||
WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid (empty) privAccount @%v", i))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for i, input := range sendTx.Inputs {
|
||||
input.PubKey = privAccounts[i].PubKey
|
||||
input.Signature = privAccounts[i].Sign(sendTx)
|
||||
}
|
||||
|
||||
WriteAPIResponse(w, API_OK, struct {
|
||||
SendTx *blk.SendTx
|
||||
}{sendTx})
|
||||
}
|
||||
|
Reference in New Issue
Block a user