Skip to content

Commit

Permalink
Merge pull request #41 from Chia-Network/get-coin-record-by-name
Browse files Browse the repository at this point in the history
Add get_coin_record_by_name endpoint
  • Loading branch information
cmmarslender committed Oct 28, 2022
2 parents 7220067 + 9bd1d51 commit 6b50a45
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/rpc/fullnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,30 @@ func (s *FullNodeService) GetBlockByHeight(opts *GetBlockByHeightOptions) (*GetB

return block, resp, nil
}

// GetCoinRecordByNameOptions request options for /get_coin_record_by_name
type GetCoinRecordByNameOptions struct {
Name string `json:"name"`
}

// GetCoinRecordByNameResponse response from get_coin_record_by_name endpoint
type GetCoinRecordByNameResponse struct {
CoinRecord types.CoinRecord `json:"coin_record"`
}

// GetCoinRecordByName request to get_coin_record_by_name endpoint
func (s *FullNodeService) GetCoinRecordByName(opts *GetCoinRecordByNameOptions) (*GetCoinRecordByNameResponse, *http.Response, error) {
request, err := s.NewRequest("get_coin_record_by_name", opts)
if err != nil {
return nil, nil, err
}

r := &GetCoinRecordByNameResponse{}

resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}
10 changes: 10 additions & 0 deletions pkg/types/coinrecord.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package types

// CoinRecord type
type CoinRecord struct {
Coin Coin `json:"coin"`
ConfirmedBlockIndex uint32 `json:"confirmed_block_index"`
SpentBlockIndex uint32 `json:"spent_block_index"`
Coinbase bool `json:"coinbase"`
Timestamp uint64 `json:"timestamp"`
}

0 comments on commit 6b50a45

Please sign in to comment.