btcjson+rpc: expose a transaction's weight via RPC
This commit is contained in:
parent
5066c212c4
commit
e3d3088b80
5 changed files with 9 additions and 1 deletions
|
@ -265,6 +265,7 @@ type GetPeerInfoResult struct {
|
|||
type GetRawMempoolVerboseResult struct {
|
||||
Size int32 `json:"size"`
|
||||
Vsize int32 `json:"vsize"`
|
||||
Weight int32 `json:"weight"`
|
||||
Fee float64 `json:"fee"`
|
||||
Time int64 `json:"time"`
|
||||
Height int64 `json:"height"`
|
||||
|
@ -505,6 +506,7 @@ type TxRawResult struct {
|
|||
Hash string `json:"hash,omitempty"`
|
||||
Size int32 `json:"size,omitempty"`
|
||||
Vsize int32 `json:"vsize,omitempty"`
|
||||
Weight int32 `json:"weight,omitempty"`
|
||||
Version int32 `json:"version"`
|
||||
LockTime uint32 `json:"locktime"`
|
||||
Vin []Vin `json:"vin"`
|
||||
|
@ -523,6 +525,7 @@ type SearchRawTransactionsResult struct {
|
|||
Hash string `json:"hash"`
|
||||
Size string `json:"size"`
|
||||
Vsize string `json:"vsize"`
|
||||
Weight string `json:"weight"`
|
||||
Version int32 `json:"version"`
|
||||
LockTime uint32 `json:"locktime"`
|
||||
Vin []VinPrevOut `json:"vin"`
|
||||
|
|
|
@ -484,7 +484,7 @@ Example Return|`{`<br /> `"bytes": 310768,`<br /> `"size":
|
|||
|Description|Returns an array of hashes for all of the transactions currently in the memory pool.<br />The `verbose` flag specifies that each transaction is returned as a JSON object.|
|
||||
|Notes|<font color="orange">Since btcd does not perform any mining, the priority related fields `startingpriority` and `currentpriority` that are available when the `verbose` flag is set are always 0.</font>|
|
||||
|Returns (verbose=false)|`[ (json array of string)`<br /> `"transactionhash", (string) hash of the transaction`<br /> `...`<br />`]`|
|
||||
|Returns (verbose=true)|`{ (json object)`<br /> `"transactionhash": { (json object)`<br /> `"size": n, (numeric) transaction size in bytes`<br /> `"vsize": n, (numeric) transaction virtual size`<br /> `"fee" : n, (numeric) transaction fee in bitcoins`<br /> `"time": n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT`<br /> `"height": n, (numeric) block height when transaction entered the pool`<br /> `"startingpriority": n, (numeric) priority when transaction entered the pool`<br /> `"currentpriority": n, (numeric) current priority`<br /> `"depends": [ (json array) unconfirmed transactions used as inputs for this transaction`<br /> `"transactionhash", (string) hash of the parent transaction`<br /> `...`<br /> `]`<br /> `}, ...`<br />`}`|
|
||||
|Returns (verbose=true)|`{ (json object)`<br /> `"transactionhash": { (json object)`<br /> `"size": n, (numeric) transaction size in bytes`<br /> `"vsize": n, (numeric) transaction virtual size`<br /> `"weight": n, (numeric) The transaction's weight (between vsize*4-3 and vsize*4)`<br /> `"fee" : n, (numeric) transaction fee in bitcoins`<br /> `"time": n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT`<br /> `"height": n, (numeric) block height when transaction entered the pool`<br /> `"startingpriority": n, (numeric) priority when transaction entered the pool`<br /> `"currentpriority": n, (numeric) current priority`<br /> `"depends": [ (json array) unconfirmed transactions used as inputs for this transaction`<br /> `"transactionhash", (string) hash of the parent transaction`<br /> `...`<br /> `]`<br /> `}, ...`<br />`}`|
|
||||
|Example Return (verbose=false)|`[`<br /> `"3480058a397b6ffcc60f7e3345a61370fded1ca6bef4b58156ed17987f20d4e7",`<br /> `"cbfe7c056a358c3a1dbced5a22b06d74b8650055d5195c1c2469e6b63a41514a"`<br />`]`|
|
||||
|Example Return (verbose=true)|`{`<br /> `"1697a19cede08694278f19584e8dcc87945f40c6b59a942dd8906f133ad3f9cc": {`<br /> `"size": 226,`<br /> `"fee" : 0.0001,`<br /> `"time": 1387992789,`<br /> `"height": 276836,`<br /> `"startingpriority": 0,`<br /> `"currentpriority": 0,`<br /> `"depends": [`<br /> `"aa96f672fcc5a1ec6a08a94aa46d6b789799c87bd6542967da25a96b2dee0afb",`<br /> `]`<br />`}`|
|
||||
[Return to Overview](#MethodOverview)<br />
|
||||
|
|
|
@ -1509,6 +1509,7 @@ func (mp *TxPool) RawMempoolVerbose() map[string]*btcjson.GetRawMempoolVerboseRe
|
|||
mpd := &btcjson.GetRawMempoolVerboseResult{
|
||||
Size: int32(tx.MsgTx().SerializeSize()),
|
||||
Vsize: int32(GetTxVirtualSize(tx)),
|
||||
Weight: int32(blockchain.GetTransactionWeight(tx)),
|
||||
Fee: btcutil.Amount(desc.Fee).ToBTC(),
|
||||
Time: desc.Added.Unix(),
|
||||
Height: int64(desc.Height),
|
||||
|
|
|
@ -756,6 +756,7 @@ func createTxRawResult(chainParams *chaincfg.Params, mtx *wire.MsgTx,
|
|||
Hash: mtx.WitnessHash().String(),
|
||||
Size: int32(mtx.SerializeSize()),
|
||||
Vsize: int32(mempool.GetTxVirtualSize(btcutil.NewTx(mtx))),
|
||||
Weight: int32(blockchain.GetTransactionWeight(btcutil.NewTx(mtx))),
|
||||
Vin: createVinList(mtx),
|
||||
Vout: createVoutList(mtx, chainParams, nil),
|
||||
Version: mtx.Version,
|
||||
|
|
|
@ -207,6 +207,7 @@ var helpDescsEnUS = map[string]string{
|
|||
"txrawresult-blocktime": "Block time in seconds since the 1 Jan 1970 GMT",
|
||||
"txrawresult-size": "The size of the transaction in bytes",
|
||||
"txrawresult-vsize": "The virtual size of the transaction in bytes",
|
||||
"txrawresult-weight": "The transaction's weight (between vsize*4-3 and vsize*4)",
|
||||
"txrawresult-hash": "The wtxid of the transaction",
|
||||
|
||||
// SearchRawTransactionsResult help.
|
||||
|
@ -223,6 +224,7 @@ var helpDescsEnUS = map[string]string{
|
|||
"searchrawtransactionsresult-blocktime": "Block time in seconds since the 1 Jan 1970 GMT",
|
||||
"searchrawtransactionsresult-size": "The size of the transaction in bytes",
|
||||
"searchrawtransactionsresult-vsize": "The virtual size of the transaction in bytes",
|
||||
"searchrawtransactionsresult-weight": "The transaction's weight (between vsize*4-3 and vsize*4)",
|
||||
|
||||
// GetBlockVerboseResult help.
|
||||
"getblockverboseresult-hash": "The hash of the block (same as provided)",
|
||||
|
@ -476,6 +478,7 @@ var helpDescsEnUS = map[string]string{
|
|||
"getrawmempoolverboseresult-currentpriority": "Current priority",
|
||||
"getrawmempoolverboseresult-depends": "Unconfirmed transactions used as inputs for this transaction",
|
||||
"getrawmempoolverboseresult-vsize": "The virtual size of a transaction",
|
||||
"getrawmempoolverboseresult-weight": "The transaction's weight (between vsize*4-3 and vsize*4)",
|
||||
|
||||
// GetRawMempoolCmd help.
|
||||
"getrawmempool--synopsis": "Returns information about all of the transactions currently in the memory pool.",
|
||||
|
|
Loading…
Reference in a new issue