diff --git a/client/rest/handlers.go b/client/rest/handlers.go index 70b9c57bb..2bf6855fb 100644 --- a/client/rest/handlers.go +++ b/client/rest/handlers.go @@ -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) } diff --git a/client/rest/types.go b/client/rest/types.go index 43af2842b..58659f818 100644 --- a/client/rest/types.go +++ b/client/rest/types.go @@ -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