Merge branch 'tendermint-rest-server-comments' into rest-server

This commit is contained in:
Emmanuel Odeke 2017-07-29 12:05:59 -06:00
commit f8c302ae45
2 changed files with 13 additions and 19 deletions

View File

@ -196,8 +196,8 @@ func doSend(w http.ResponseWriter, r *http.Request) {
if si.To == nil {
errsList = append(errsList, `"to" cannot be nil`)
}
if si.Fees == nil {
errsList = append(errsList, `"fees" cannot be nil`)
if len(si.Amount) == 0 {
errsList = append(errsList, `"amount" cannot be empty`)
}
if len(errsList) > 0 {
err := &ErrorResponse{
@ -208,21 +208,13 @@ func doSend(w http.ResponseWriter, r *http.Request) {
return
}
coins := []coin.Coin{*si.Fees}
in := []coin.TxInput{
coin.NewTxInput(*si.From, coins),
}
out := []coin.TxOutput{
coin.NewTxOutput(*si.To, coins),
}
tx := coin.NewSendTx(in, out)
tx = fee.NewFee(tx, *si.Fees, *si.From)
signers := []basecoin.Actor{
*si.From,
*si.To,
tx := coin.NewSendOneTx(*si.From, *si.To, si.Amount)
// fees are optional
if si.Fees != nil && !si.Fees.IsZero() {
tx = fee.NewFee(tx, *si.Fees, *si.From)
}
// only add the actual signer to the nonce
signers := []basecoin.Actor{*si.From}
tx = nonce.NewTx(si.Sequence, signers, tx)
tx = base.NewChainTx(commands.GetChainID(), 0, tx)
@ -231,4 +223,5 @@ func doSend(w http.ResponseWriter, r *http.Request) {
} else {
tx = auth.NewSig(tx).Wrap()
}
writeSuccess(w, tx)
}

View File

@ -60,12 +60,13 @@ type CreateKeyResponse struct {
// many fields so it would be nice to figure out all the invalid
// inputs and report them back to the caller, in one shot.
type SendInput struct {
Fees *coin.Coin `json:"amount"`
Fees *coin.Coin `json:"fees"`
Multi bool `json:"multi,omitempty"`
Sequence uint32 `json:"sequence"`
To *basecoin.Actor `json:"to"`
From *basecoin.Actor `json:"from"`
To *basecoin.Actor `json:"to"`
From *basecoin.Actor `json:"from"`
Amount coin.Coins `json:"amount"`
}
// Validators