From a1771466b7d071d4c3369cad37d028d0e545608d Mon Sep 17 00:00:00 2001 From: Brannon King Date: Tue, 9 Nov 2021 14:59:07 -0500 Subject: [PATCH] added missing takeover height and amount RPC fields --- btcjson/claimcmds.go | 12 +++++++----- rpcclaimtrie.go | 37 +++++++++++++++++++++---------------- rpcserverhelp.go | 11 ++++++----- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/btcjson/claimcmds.go b/btcjson/claimcmds.go index cb98fbf8..8f50fc0c 100644 --- a/btcjson/claimcmds.go +++ b/btcjson/claimcmds.go @@ -55,11 +55,12 @@ type GetClaimsForNameBySeqCmd struct { } type GetClaimsForNameResult struct { - Hash string `json:"hash"` - Height int32 `json:"height"` - NormalizedName string `json:"normalizedname"` - Claims []ClaimResult `json:"claims"` - // UnclaimedSupports []SupportResult `json:"unclaimedSupports"` how would this work with other constraints? + Hash string `json:"hash"` + Height int32 `json:"height"` + LastTakeoverHeight int32 `json:"lasttakeoverheight"` + NormalizedName string `json:"normalizedname"` + Claims []ClaimResult `json:"claims"` + // UnclaimedSupports []SupportResult `json:"supportswithoutclaim"` how would this work with other constraints? } type SupportResult struct { @@ -80,6 +81,7 @@ type ClaimResult struct { Sequence int32 `json:"sequence"` Height int32 `json:"height"` ValidAtHeight int32 `json:"validatheight"` + Amount int64 `json:"amount"` EffectiveAmount int64 `json:"effectiveamount"` Supports []SupportResult `json:"supports,omitempty"` Address string `json:"address,omitempty"` diff --git a/rpcclaimtrie.go b/rpcclaimtrie.go index 837eafc0..f452e498 100644 --- a/rpcclaimtrie.go +++ b/rpcclaimtrie.go @@ -117,10 +117,11 @@ func handleGetClaimsForName(s *rpcServer, cmd interface{}, _ <-chan struct{}) (i } return btcjson.GetClaimsForNameResult{ - Hash: hash, - Height: height, - NormalizedName: name, - Claims: results, + Hash: hash, + Height: height, + LastTakeoverHeight: n.TakenOverAt, + NormalizedName: name, + Claims: results, }, nil } @@ -155,10 +156,11 @@ func handleGetClaimsForNameByID(s *rpcServer, cmd interface{}, _ <-chan struct{} } return btcjson.GetClaimsForNameResult{ - Hash: hash, - Height: height, - NormalizedName: name, - Claims: results, + Hash: hash, + Height: height, + LastTakeoverHeight: n.TakenOverAt, + NormalizedName: name, + Claims: results, }, nil } @@ -190,10 +192,11 @@ func handleGetClaimsForNameByBid(s *rpcServer, cmd interface{}, _ <-chan struct{ } return btcjson.GetClaimsForNameResult{ - Hash: hash, - Height: height, - NormalizedName: name, - Claims: results, + Hash: hash, + Height: height, + LastTakeoverHeight: n.TakenOverAt, + NormalizedName: name, + Claims: results, }, nil } @@ -230,10 +233,11 @@ func handleGetClaimsForNameBySeq(s *rpcServer, cmd interface{}, _ <-chan struct{ } return btcjson.GetClaimsForNameResult{ - Hash: hash, - Height: height, - NormalizedName: name, - Claims: results, + Hash: hash, + Height: height, + LastTakeoverHeight: n.TakenOverAt, + NormalizedName: name, + Claims: results, }, nil } @@ -248,6 +252,7 @@ func toClaimResult(s *rpcServer, i int32, node *node.Node, includeValues *bool) TXID: claim.OutPoint.Hash.String(), N: claim.OutPoint.Index, Bid: i, // assuming sorted by bid + Amount: claim.Amount, EffectiveAmount: claim.Amount + node.SupportSums[claim.ClaimID.Key()], Sequence: claim.Sequence, Supports: supports, diff --git a/rpcserverhelp.go b/rpcserverhelp.go index 449cb712..2d191649 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -782,10 +782,11 @@ var helpDescsEnUS = map[string]string{ "getclaimsfornamebybid-includevalues": "Return the metadata and address", "getclaimsfornamebyid-includevalues": "Return the metadata and address", - "getclaimsfornameresult-claims": "All the active claims on the given name", - "getclaimsfornameresult-normalizedname": "Lower-case version of the passed-in name", - "getclaimsfornameresult-height": "Height of the requested block", - "getclaimsfornameresult-hash": "Hash of the requested block", + "getclaimsfornameresult-claims": "All the active claims on the given name", + "getclaimsfornameresult-normalizedname": "Lower-case version of the passed-in name", + "getclaimsfornameresult-height": "Height of the requested block", + "getclaimsfornameresult-lasttakeoverheight": "Height of the most recent name takeover", + "getclaimsfornameresult-hash": "Hash of the requested block", "getchangesinblock--synopsis": "Returns a list of names affected by a given block", "getchangesinblockresult-names": "Names that changed (or were at least checked for change) on the given height", @@ -806,9 +807,9 @@ var helpDescsEnUS = map[string]string{ "claimresult-n": "The output (TXO) index", "claimresult-address": "The destination address for the claim", "claimresult-supports": "The list of supports active on the claim", - "claimresult-amount": "LBC staked", "claimresult-validatheight": "The height when the stake becomes valid", "claimresult-height": "The height when the stake was created or updated", + "claimresult-amount": "The stake amount in sats", "claimresult-effectiveamount": "The stake amount plus the active supports' amounts", "claimresult-sequence": "The order this claim was created compared to other claims on this name", "claimresult-bid": "Bid of 0 means that this claim currently owns the name",