@@ -137,6 +137,7 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
137137 "decoderawtransaction" : handleDecodeRawTransaction ,
138138 "decodescript" : handleDecodeScript ,
139139 "estimatefee" : handleEstimateFee ,
140+ "estimatesmartfee" : handleEstimateSmartFee ,
140141 "generate" : handleGenerate ,
141142 "generatetoaddress" : handleGenerateToAddress ,
142143 "getaddednodeinfo" : handleGetAddedNodeInfo ,
@@ -879,23 +880,40 @@ func handleEstimateFee(s *rpcServer, cmd interface{}, closeChan <-chan struct{})
879880 c := cmd .(* btcjson.EstimateFeeCmd )
880881
881882 if s .cfg .FeeEstimator == nil {
882- return nil , errors .New ("Fee estimation disabled" )
883+ return nil , & btcjson.RPCError {
884+ Code : btcjson .ErrRPCInternal .Code ,
885+ Message : "Fee estimation disabled" ,
886+ }
883887 }
884888
885889 if c .NumBlocks <= 0 {
886- return - 1.0 , errors .New ("Parameter NumBlocks must be positive" )
890+ return nil , & btcjson.RPCError {
891+ Code : btcjson .ErrRPCInvalidParameter ,
892+ Message : "Parameter NumBlocks must be positive" ,
893+ }
887894 }
888895
889896 feeRate , err := s .cfg .FeeEstimator .EstimateFee (uint32 (c .NumBlocks ))
890897
891898 if err != nil {
892- return - 1.0 , err
899+ return nil , & btcjson.RPCError {
900+ Code : btcjson .ErrRPCInvalidParameter ,
901+ Message : err .Error (),
902+ }
893903 }
894904
895905 // Convert to satoshis per kb.
896906 return float64 (feeRate ), nil
897907}
898908
909+ func handleEstimateSmartFee (s * rpcServer , cmd interface {}, closeChan <- chan struct {}) (interface {}, error ) {
910+ c := cmd .(* btcjson.EstimateSmartFeeCmd )
911+
912+ rpcsLog .Debugf ("EstimateSmartFee is not implemented; falling back to EstimateFee. Requested mode: %s" , c .EstimateMode )
913+
914+ return handleEstimateFee (s , & btcjson.EstimateFeeCmd {NumBlocks : c .ConfTarget }, closeChan )
915+ }
916+
899917func handleGenerate (s * rpcServer , cmd interface {}, closeChan <- chan struct {}) (interface {}, error ) {
900918 // Respond with an error if there are no addresses to pay the
901919 // created blocks to.
0 commit comments