Correct getrawmempool verbose fee field.

The fee field of the getrawmempool RPC JSON response should be in Bitcoins
instead of Satoshi.  This commit corrects that issue.

Also, add a couple of comments and fix a comment typo while here.
This commit is contained in:
Dave Collins 2013-12-25 12:28:54 -06:00
parent edf8f2f224
commit dc200d002e
2 changed files with 11 additions and 4 deletions

View file

@ -958,7 +958,7 @@ func (mp *txMemPool) processOrphans(hash *btcwire.ShaHash) error {
}
// ProcessTransaction is the main workhorse for handling insertion of new
// free-standing transactions into a memory pool. It includes functionality
// free-standing transactions into the memory pool. It includes functionality
// such as rejecting duplicate transactions, ensuring transactions follow all
// rules, orphan transaction handling, and insertion into the memory pool.
//

View file

@ -870,9 +870,12 @@ func handleGetPeerInfo(s *rpcServer, cmd btcjson.Cmd, walletNotification chan []
return s.server.PeerInfo(), nil
}
// mempoolDescriptor describes a JSON object which is returned for each
// transaction in the memory pool in response to a getrawmempool command with
// the verbose flag set.
type mempoolDescriptor struct {
Size int `json:"size"`
Fee int64 `json:"fee"`
Fee float64 `json:"fee"`
Time int64 `json:"time"`
Height int64 `json:"height"`
StartingPriority int `json:"startingpriority"`
@ -889,8 +892,9 @@ func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd, walletNotification chan
result := make(map[string]*mempoolDescriptor, len(descs))
for _, desc := range descs {
mpd := &mempoolDescriptor{
Size: desc.Tx.MsgTx().SerializeSize(),
Fee: desc.Fee,
Size: desc.Tx.MsgTx().SerializeSize(),
Fee: float64(desc.Fee) /
float64(btcutil.SatoshiPerBitcoin),
Time: desc.Added.Unix(),
Height: desc.Height,
StartingPriority: 0, // We don't mine.
@ -909,6 +913,9 @@ func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd, walletNotification chan
return result, nil
}
// The response is simply an array of the transaction hashes if the
// verbose flag is not set.
hashStrings := make([]string, len(descs))
for i := range hashStrings {
hashStrings[i] = descs[i].Tx.Sha().String()