Skip to content

Commit

Permalink
Add total supply api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Feb 19, 2019
1 parent 157e8d8 commit 29fab0a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions server/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ func (s *PublicServer) ConnectFullPublicInterface() {
serveMux.HandleFunc(path+"api/block/", s.jsonHandler(s.apiBlock))
serveMux.HandleFunc(path+"api/sendtx/", s.jsonHandler(s.apiSendTx))
serveMux.HandleFunc(path+"api/estimatefee/", s.jsonHandler(s.apiEstimateFee))
serveMux.HandleFunc(path+"api/totalbc/", s.jsonHandler(s.apiTotalBc))
serveMux.HandleFunc(path+"api/totalcoins/", s.jsonHandler(s.apiTotalCoins))
// socket.io interface
serveMux.Handle(path+"socket.io/", s.socketio.GetHandler())
}
Expand Down Expand Up @@ -653,6 +655,34 @@ func (s *PublicServer) apiBlockIndex(r *http.Request) (interface{}, error) {
}, nil
}

func (s *PublicServer) apiTotalBc(r *http.Request) (interface{}, error) {
var err error
var supplyAmount json.Number

si, err := s.api.GetSystemInfo(true)
if err != nil {
return nil, err
}

supplyAmount = si.Backend.MoneySupply

return supplyAmount, nil
}

func (s *PublicServer) apiTotalCoins(r *http.Request) (interface{}, error) {
var err error
var supply string

supplyAmount, err := s.apiTotalBc(r)
if err != nil {
return nil, err
}
supplyNumber := supplyAmount.(json.Number)
supply = formatSatoshis(json.Number(supplyNumber))

return supply, nil
}

func (s *PublicServer) apiTx(r *http.Request) (interface{}, error) {
var tx *api.Tx
var err error
Expand Down

0 comments on commit 29fab0a

Please sign in to comment.