diff --git a/dcrjson/chainsvrresults.go b/dcrjson/chainsvrresults.go index 34486758..9945a339 100644 --- a/dcrjson/chainsvrresults.go +++ b/dcrjson/chainsvrresults.go @@ -326,7 +326,7 @@ type TxRawResult struct { Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` - BlockHeight int64 `json:"blockheight"` + BlockHeight int64 `json:"blockheight,omitempty"` BlockIndex uint32 `json:"blockindex,omitempty"` Confirmations int64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` @@ -510,9 +510,12 @@ type SearchRawTransactionsResult struct { Txid string `json:"txid"` Version int32 `json:"version"` LockTime uint32 `json:"locktime"` + Expiry uint32 `json:"expiry"` Vin []VinPrevOut `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` + BlockHeight int64 `json:"blockheight,omitempty"` + BlockIndex uint32 `json:"blockindex,omitempty"` Confirmations uint64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` diff --git a/dcrjson/chainsvrwsntfns_test.go b/dcrjson/chainsvrwsntfns_test.go index c1823eca..8b4b260b 100644 --- a/dcrjson/chainsvrwsntfns_test.go +++ b/dcrjson/chainsvrwsntfns_test.go @@ -98,7 +98,7 @@ func TestChainSvrWsNtfns(t *testing.T) { } return NewTxAcceptedVerboseNtfn(txResult) }, - marshalled: `{"jsonrpc":"1.0","method":"txacceptedverbose","params":[{"hex":"001122","txid":"123","version":1,"locktime":4294967295,"expiry":0,"vin":null,"vout":null,"blockheight":0}],"id":null}`, + marshalled: `{"jsonrpc":"1.0","method":"txacceptedverbose","params":[{"hex":"001122","txid":"123","version":1,"locktime":4294967295,"expiry":0,"vin":null,"vout":null}],"id":null}`, unmarshalled: &TxAcceptedVerboseNtfn{ RawTx: TxRawResult{ Hex: "001122", diff --git a/docs/json_rpc_api.md b/docs/json_rpc_api.md index 7479ed1e..5947025d 100644 --- a/docs/json_rpc_api.md +++ b/docs/json_rpc_api.md @@ -462,7 +462,7 @@ the method name for further details such as parameter and return information. |Parameters|1. `transaction hash`: `(string, required)` the hash of the transaction.
2. `verbose`: `(int, optional, default=0)` specifies the transaction is returned as a JSON object instead of hex-encoded string.| |Description|Returns information about a transaction given its hash.| |Returns (verbose=0)|`"data" (string) hex-encoded bytes of the serialized transaction`| -|Returns (verbose=1)|`(json object)`
`hex`: `(string)` hex-encoded transaction / hex-encoded bytes of the script.
`txid`: `(string)` the hash of the transaction.
`version`: `(numeric)` the transaction version.
`locktime`: `(numeric)` the transaction lock time.
`vin`: `(array of json objects)` the transaction inputs as json objects.
`coinbase`: `(string)` the hex-encoded bytes of the signature script.
`stakebase`: `(string)` the hash of the stake transaction.
`sequence`: `(numeric)` the script sequence number.
`txid`: `(string)` the hash of the origin transaction.
`vout`: `(numeric)` the index of the output being redeemed from the origin transaction.
`scriptSig`: `(json object)` the signature script used to redeem the origin transaction.
`asm`: `(string)` disassembly of the script.
`sequence`: `(numeric)` the script sequence number.
`vout`: `(array of json objects)` the transaction outputs as json objects.
`value`: `(numeric)` the value in DCR.
`n`: `(numeric)` the index of this transaction output.
`scriptPubKey`: `(json object)` the public key script used to pay coins.
`reqSigs`: `(numeric)` the number of required signatures.
`type`: `(string)` the type of the script (e.g. 'pubkeyhash').
`addresses`: `(json array of string)` the Decred addresses associated with this output.
`decredaddress`: `(string)` the Decred address

**For coinbase transactions**
`{"hex": "data", "txid": "hash", "version": n, "locktime": n, "vin": [{ "coinbase": "data", "sequence": n}, ...], "vout": [{"value": n, "n": n,"scriptPubKey": { "asm": "asm","hex": "data", "reqSigs": n,"type": "scripttype", "addresses": [ "decredaddress", ...]}}, ...]}`

**For stakebase transactions**
`{"hex": "data", "txid": "hash", "version": n, "locktime": n, "vin": [{ "stakebase": "hash", "sequence": n}, ...], "vout": [{"value": n, "n": n,"scriptPubKey": { "asm": "asm","hex": "data", "reqSigs": n,"type": "scripttype", "addresses": [ "decredaddress", ...]}}, ...]}`

**For non-coinbase / non-stakebase transactions**
`{"hex": "data", "txid": "hash", "version": n, "locktime": n, "vin": [{"txid": "hash","vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "sequence": n}, ...], "vout": [{"value": n, "n": n,"scriptPubKey": { "asm": "asm","hex": "data", "reqSigs": n,"type": "scripttype", "addresses": [ "decredaddress", ...]}}, ...]}`| +|Returns (verbose=1)|`(json object)`
`hex`: `(string)` hex-encoded transaction / hex-encoded bytes of the script.
`txid`: `(string)` the hash of the transaction.
`version`: `(numeric)` the transaction version.
`locktime`: `(numeric)` the transaction lock time.
`expiry`: `(numeric)` the transaction expiry.
`vin`: `(array of json objects)` the transaction inputs as json objects.
`coinbase`: `(string)` the hex-encoded bytes of the signature script.
`stakebase`: `(string)` the hash of the stake transaction.
`sequence`: `(numeric)` the script sequence number.
`txid`: `(string)` the hash of the origin transaction.
`vout`: `(numeric)` the index of the output being redeemed from the origin transaction.
`scriptSig`: `(json object)` the signature script used to redeem the origin transaction.
`asm`: `(string)` disassembly of the script.
`sequence`: `(numeric)` the script sequence number.
`vout`: `(array of json objects)` the transaction outputs as json objects.
`value`: `(numeric)` the value in DCR.
`n`: `(numeric)` the index of this transaction output.
`scriptPubKey`: `(json object)` the public key script used to pay coins.
`reqSigs`: `(numeric)` the number of required signatures.
`type`: `(string)` the type of the script (e.g. 'pubkeyhash').
`addresses`: `(json array of string)` the Decred addresses associated with this output.
`decredaddress`: `(string)` the Decred address
`blockhash`: `(string)` the hash of the block that contains the transaction.
`blockheight`: `(numeric)` the height of the block that contains the transaction.
`blockindex`: `(numeric)` the index within the array of transactions contained by the block.
`confirmations`: `(numeric)` number of confirmations.
`time`: `(numeric)` transaction time in seconds since the epoch.
`blocktime`: `(numeric)` block time in seconds since the epoch.

**For coinbase transactions**
`{"hex": "data", "txid": "hash", "version": n, "locktime": n, "expiry": n, vin": [{ "coinbase": "data", "sequence": n}, ...], "vout": [{"value": n, "n": n,"scriptPubKey": { "asm": "asm","hex": "data", "reqSigs": n,"type": "scripttype", "addresses": [ "decredaddress", ...]}}, ...], "blockhash": "hash", "blockheight": n, "confirmations": n, "blocktime": n}`

**For stakebase transactions**
`{"hex": "data", "txid": "hash", "version": n, "locktime": n, "expiry": n, "vin": [{ "stakebase": "hash", "sequence": n}, ...], "vout": [{"value": n, "n": n,"scriptPubKey": { "asm": "asm","hex": "data", "reqSigs": n,"type": "scripttype", "addresses": [ "decredaddress", ...]}}, ...], "blockhash": "hash", "blockheight": n, "blockindex": n, "confirmations": n, "time": n, blocktime": n}`

**For non-coinbase / non-stakebase transactions**
`{"hex": "data", "txid": "hash", "version": n, "locktime": n, "expiry": n, "vin": [{"txid": "hash","vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "sequence": n}, ...], "vout": [{"value": n, "n": n,"scriptPubKey": { "asm": "asm","hex": "data", "reqSigs": n,"type": "scripttype", "addresses": [ "decredaddress", ...]}}, ...], "blockhash": "hash", "blockheight": n, "blockindex": n, "confirmations": n, "time": n, "blocktime": n}`| |Example Return (verbose=0)|Newlines added for display purposes. The actual return does not contain newlines.
`"010000000104be666c7053ef26c6110597dad1c1e81b5e6be53d17a8b9d0b34772054bac60000000`
`008c493046022100cb42f8df44eca83dd0a727988dcde9384953e830b1f8004d57485e2ede1b9c8f`
`022100fbce8d84fcf2839127605818ac6c3e7a1531ebc69277c504599289fb1e9058df0141045a33`
`76eeb85e494330b03c1791619d53327441002832f4bd618fd9efa9e644d242d5e1145cb9c2f71965`
`656e276633d4ff1a6db5e7153a0a9042745178ebe0f5ffffffff0280841e00000000001976a91406`
`f1b6703d3f56427bfcfd372f952d50d04b64bd88ac4dd52700000000001976a9146b63f291c295ee`
`abd9aee6be193ab2d019e7ea7088ac00000000`| |Example Return (verbose=1)|**For coinbase transactions**
`{"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000f...","txid": "90743aad855880e517270550d2a881627d84db5265142fd1e7fb7add38b08be9","version": 1,"locktime": 0,"vin": [{"coinbase": "03708203062f503253482f04066d605108f800080100000ea2122f6f7a636f696e4065757374726174756d2f","sequence": 0},...], "vout": [{"value": 25.1394,"n": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 ea132286328cfc819457b9dec386c4b5c84faa5c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914ea132286328cfc819457b9dec386c4b5c84faa5c88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["1NLg3QJMsMQGM5KEUaEu5ADDmKQSLHwmyh", ...]}}, ...]}`

**For stakebase transactions**
`{"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000f...","txid": "90743aad855880e517270550d2a881627d84db5265142fd1e7fb7add38b08be9","version": 1,"locktime": 0,"vin": [{"stakebase": "90743aad855880e517270550d2a881627d84db5265142fd1e7fb7add38b08be9","sequence": 0},...], "vout": [{"value": 25.1394,"n": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 ea132286328cfc819457b9dec386c4b5c84faa5c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914ea132286328cfc819457b9dec386c4b5c84faa5c88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["1NLg3QJMsMQGM5KEUaEu5ADDmKQSLHwmyh", ...]}}, ...]}`

**For non-coinbase / non-stakebase transactions**
`{"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000f...","txid": "90743aad855880e517270550d2a881627d84db5265142fd1e7fb7add38b08be9","version": 1,"locktime": 0,"vin": [{"txid": "60ac4b057247b3d0b9a8173de56b5e1be8c1d1da970511c626ef53706c66be04","scriptSig": {"asm": "3046022100cb42f8df44eca83dd0a727988dcde9384953e830b1f8004d57485e2ede1b9c8f0...","hex": "493046022100cb42f8df44eca83dd0a727988dcde9384953e830b1f8004d57485e2ede1b9c8..."}, "sequence": 4294967295}, ...], "vout": [{"value": 25.1394,"n": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 ea132286328cfc819457b9dec386c4b5c84faa5c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914ea132286328cfc819457b9dec386c4b5c84faa5c88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["1NLg3QJMsMQGM5KEUaEu5ADDmKQSLHwmyh", ...]}}, ...]}`| [Return to Overview](#MethodOverview)
@@ -639,7 +639,7 @@ the method name for further details such as parameter and return information. |Parameters|1. `address`: `(string, required)` Decred address.
2. `verbose`: `(int, optional, default=true)` specifies the transaction is returned as a JSON object instead of hex-encoded string.
3. `skip`: `(int, optional, default=0)` the number of leading transactions to leave out of the final response.
4. `count`: `(int, optional, default=100)` the maximum number of transactions to return.
5. `vinextra`: `(int, optional, default=0)` specify that extra data from previous output will be returned in vin.| |Description|Returns raw data for transactions involving the passed address. Returned transactions are pulled from both the database, and transactions currently in the mempool. Transactions pulled from the mempool will have the `"confirmations"` field set to 0. Usage of this RPC requires the optional `--addrindex` flag to be activated, otherwise all responses will simply return with an error stating the address index has not yet been built up. Similarly, until the address index has caught up with the current best height, all requests will return an error response in order to avoid serving stale data.| |Returns (verbose=0)|`(json array of strings)`
`serializedtx`: `(string)` hex-encoded bytes of the serialized transaction.
`["serializedtx", ... ]` | -|Returns (verbose=1)|`(array of json objects)`
`hex`: `(string)` hex-encoded transaction.
`txid`: `(string)` the hash of the transaction.
`version`: `(numeric)` the transaction version.
`locktime`: `(numeric)` the transaction lock time.
`vin`: `(json array)` the transaction inputs as json objects.
`coinbase`: `(string)` the hex-encoded bytes of the signature script.
`stakebase`: `(string)` the hash of the stake transaction.
`sequence`: `(numeric)` the script sequence number.
`txid`: `(string)` the hash of the origin transaction.
`vout`: `(numeric)` the index of the output being redeemed from the origin transaction.
`scriptSig`: `(json object)` the signature script used to redeem the origin transaction.
`asm`: `(string)` disassembly of the script.
`hex`: `(string)` hex-encoded bytes of the script.
`prevOut`: Data from the origin transaction output with index vout.
`addresses`: `(array of string)` previous output addresses.
`value`: `(numeric)` previous output value.
`sequence`: `(numeric)` the script sequence number.
`vout`: `(array of json objects)` the transaction outputs as json objects.
`value`: `(numeric)` the value in DCR.
`n`: `(numeric)` the index of this transaction output.
`scriptPubKey`: `(json object)` the public key script used to pay coins.
`asm`: `(string)` disassembly of the script.
`hex`: `(string)` hex-encoded bytes of the script.
`reqSigs`: `(numeric)` the number of required signatures.
`type`: `(string)` the type of the script (e.g. 'pubkeyhash').
`addresses`: `(json array of string)` the Decred addresses associated with this output.
`address`: `(string)` the Decred address.
`blockhash`: `(string)` hash of the block the transaction is part of.
`confirmations`: `(numeric)` number of numeric confirmations of block.
`time`: `(numeric)` transaction time in seconds since the epoch.
`blocktime`: `(numeric)` block time in seconds since the epoch.

**For coinbase transactions**
`[{"hex": "data", "txid": "hash", "version": n, "locktime": n,"vin": [{"coinbase": "data", "sequence": n},{"txid": "hash", "vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "prevOut": {"addresses": ["value", ...], "value": n.nnn}, "sequence": n}, ...],"vout": [{ "value": n,"n": n, "scriptPubKey": {"asm": "asm", "hex": "data", "reqSigs": n, "type": "scripttype", "addresses": ["address", ...]}}, ...], "blockhash":"hash", "confirmations":n, "time":t, "blocktime":t },...]`

**For stakebase transactions**
`[{"hex": "data", "txid": "hash", "version": n, "locktime": n,"vin": [{"stakebase": "hash", "sequence": n},{"txid": "hash", "vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "prevOut": {"addresses": ["value", ...], "value": n.nnn}, "sequence": n}, ...],"vout": [{ "value": n,"n": n, "scriptPubKey": {"asm": "asm", "hex": "data", "reqSigs": n, "type": "scripttype", "addresses": ["address", ...]}}, ...], "blockhash":"hash", "confirmations":n, "time":t, "blocktime":t },...]`

**For non-coinbase / non-stakebase transactions**
`[{"hex": "data", "txid": "hash", "version": n, "locktime": n,"vin": [{"txid": "hash", "vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "prevOut": {"addresses": ["value",...], "value": n.nnn}, "sequence": n}, ...],"vout": [{ "value": n,"n": n, "scriptPubKey": {"asm": "asm", "hex": "data", "reqSigs": n, "type": "scripttype", "addresses": ["address", ...]}}, ...], "blockhash":"hash", "confirmations":n, "time":t, "blocktime":t },...]`| +|Returns (verbose=1)|`(array of json objects)`
`hex`: `(string)` hex-encoded transaction.
`txid`: `(string)` the hash of the transaction.
`version`: `(numeric)` the transaction version.
`locktime`: `(numeric)` the transaction lock time.
`expiry`: `(numeric)` the transaction expiry.
`vin`: `(json array)` the transaction inputs as json objects.
`coinbase`: `(string)` the hex-encoded bytes of the signature script.
`stakebase`: `(string)` the hash of the stake transaction.
`sequence`: `(numeric)` the script sequence number.
`txid`: `(string)` the hash of the origin transaction.
`vout`: `(numeric)` the index of the output being redeemed from the origin transaction.
`scriptSig`: `(json object)` the signature script used to redeem the origin transaction.
`asm`: `(string)` disassembly of the script.
`hex`: `(string)` hex-encoded bytes of the script.
`prevOut`: Data from the origin transaction output with index vout.
`addresses`: `(array of string)` previous output addresses.
`value`: `(numeric)` previous output value.
`sequence`: `(numeric)` the script sequence number.
`vout`: `(array of json objects)` the transaction outputs as json objects.
`value`: `(numeric)` the value in DCR.
`n`: `(numeric)` the index of this transaction output.
`scriptPubKey`: `(json object)` the public key script used to pay coins.
`asm`: `(string)` disassembly of the script.
`hex`: `(string)` hex-encoded bytes of the script.
`reqSigs`: `(numeric)` the number of required signatures.
`type`: `(string)` the type of the script (e.g. 'pubkeyhash').
`addresses`: `(json array of string)` the Decred addresses associated with this output.
`address`: `(string)` the Decred address.
`blockhash`: `(string)` the hash of the block that contains the transaction.
`blockheight`: `(numeric)` the height of the block that contains the transaction.
`blockindex`: `(numeric)` the index within the array of transactions contained by the block.
`confirmations`: `(numeric)` number of confirmations.
`time`: `(numeric)` transaction time in seconds since the epoch.
`blocktime`: `(numeric)` block time in seconds since the epoch.

**For coinbase transactions**
`[{"hex": "data", "txid": "hash", "version": n, "locktime": n,"vin": [{"coinbase": "data", "sequence": n},{"txid": "hash", "vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "prevOut": {"addresses": ["value", ...], "value": n.nnn}, "sequence": n}, ...],"vout": [{ "value": n, "n": n, "scriptPubKey": {"asm": "asm", "hex": "data", "reqSigs": n, "type": "scripttype", "addresses": ["address", ...]}}, ...], "blockhash": "hash", "blockheight": n, confirmations": n, "time": n, "blocktime": n},...]`

**For stakebase transactions**
`[{"hex": "data", "txid": "hash", "version": n, "locktime": n,"vin": [{"stakebase": "hash", "sequence": n},{"txid": "hash", "vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "prevOut": {"addresses": ["value", ...], "value": n.nnn}, "sequence": n}, ...],"vout": [{ "value": n,"n": n, "scriptPubKey": {"asm": "asm", "hex": "data", "reqSigs": n, "type": "scripttype", "addresses": ["address", ...]}}, ...], "blockhash": "hash", "blockheight": n, "blockindex": n, confirmations": n, "time": n, "blocktime": n},...]`

**For non-coinbase / non-stakebase transactions**
`[{"hex": "data", "txid": "hash", "version": n, "locktime": n,"vin": [{"txid": "hash", "vout": n, "scriptSig": {"asm": "asm", "hex": "data"}, "prevOut": {"addresses": ["value",...], "value": n.nnn}, "sequence": n}, ...],"vout": [{ "value": n,"n": n, "scriptPubKey": {"asm": "asm", "hex": "data", "reqSigs": n, "type": "scripttype", "addresses": ["address", ...]}}, ...], "blockhash":"hash", "blockheight": n, "blockindex": n, confirmations": n, "time": n, "blocktime": n},...]`| [Return to Overview](#ExtMethodOverview)
*** diff --git a/rpcserver.go b/rpcserver.go index 0c6a37da..deea4e00 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3516,6 +3516,7 @@ func handleGetRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan str var mtx *wire.MsgTx var blkHash *chainhash.Hash var blkHeight int64 + var blkIndex uint32 tx, err := s.server.txMemPool.FetchTransaction(txHash, true) if err != nil { txIndex := s.server.txIndex @@ -3553,13 +3554,14 @@ func handleGetRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan str return hex.EncodeToString(txBytes), nil } - // Grab the block height. + // Grab the block details. blkHash = blockRegion.Hash blkHeight, err = s.chain.BlockHeightByHash(blkHash) if err != nil { context := "Failed to retrieve block height" return nil, rpcInternalError(err.Error(), context) } + blkIndex = wire.NullBlockIndex // TODO: Update txindex to provide. // Deserialize the transaction var msgTx wire.MsgTx @@ -3607,9 +3609,8 @@ func handleGetRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan str confirmations = 1 + s.chain.BestSnapshot().Height - blkHeight } - rawTxn, err := createTxRawResult(s.server.chainParams, mtx, - txHash.String(), 0, blkHeader, blkHashStr, blkHeight, - confirmations) + rawTxn, err := createTxRawResult(s.server.chainParams, mtx, txHash.String(), + blkIndex, blkHeader, blkHashStr, blkHeight, confirmations) if err != nil { return nil, err } @@ -4528,9 +4529,10 @@ func handleRebroadcastWinners(s *rpcServer, cmd interface{}, closeChan <-chan st // This is mainly done for efficiency to avoid extra serialization steps when // possible. type retrievedTx struct { - txBytes []byte - blkHash *chainhash.Hash // Only set when transaction is in a block. - tx *dcrutil.Tx + txBytes []byte + blkHash *chainhash.Hash // Only set when transaction is in a block. + blkIndex uint32 // Only set when transaction is in a block. + tx *dcrutil.Tx } // fetchInputTxos fetches the outpoints from all transactions referenced by the @@ -4839,8 +4841,8 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan addressTxns := make([]retrievedTx, 0, numRequested) if reverse { // Transactions in the mempool are not in a block header yet, - // so the block header field in the retieved transaction struct - // is left nil. + // so the block header and block index fields in the retrieved + // transaction struct are left unset. mpTxns, mpSkipped := fetchMempoolTxnsForAddress(s, addr, uint32(numToSkip), uint32(numRequested)) numSkipped += mpSkipped @@ -4872,10 +4874,13 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan // requested non-verbose output and hence there would // be no point in deserializing it just to reserialize // it later. + // + // TODO: Update txindex to provide block index. for i, serializedTx := range serializedTxns { addressTxns = append(addressTxns, retrievedTx{ - txBytes: serializedTx, - blkHash: regions[i].Hash, + txBytes: serializedTx, + blkHash: regions[i].Hash, + blkIndex: wire.NullBlockIndex, }) } numSkipped += dbSkipped @@ -4978,6 +4983,7 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan result.Vout = createVoutList(mtx, chainParams, filterAddrMap) result.Version = int32(mtx.Version) result.LockTime = mtx.LockTime + result.Expiry = mtx.Expiry // Transactions grabbed from the mempool aren't yet in a block, // so conditionally fetch block details here. This will be @@ -4986,6 +4992,7 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan var blkHeader *wire.BlockHeader var blkHashStr string var blkHeight int64 + var blkIndex uint32 if blkHash := rtx.blkHash; blkHash != nil { // Fetch the header from chain. header, err := s.chain.HeaderByHash(blkHash) @@ -5006,6 +5013,7 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan blkHeader = &header blkHashStr = blkHash.String() blkHeight = height + blkIndex = rtx.blkIndex } // Add the block information to the result if there is any. @@ -5015,6 +5023,8 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan result.Time = blkHeader.Timestamp.Unix() result.Blocktime = blkHeader.Timestamp.Unix() result.BlockHash = blkHashStr + result.BlockHeight = blkHeight + result.BlockIndex = blkIndex result.Confirmations = uint64(1 + best.Height - blkHeight) } } diff --git a/rpcserverhelp.go b/rpcserverhelp.go index bab1aef4..7eb51724 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -251,12 +251,12 @@ var helpDescsEnUS = map[string]string{ "txrawresult-locktime": "The transaction lock time", "txrawresult-vin": "The transaction inputs as JSON objects", "txrawresult-vout": "The transaction outputs as JSON objects", - "txrawresult-blockhash": "Hash of the block the transaction is part of", + "txrawresult-blockhash": "The hash of the block that contains the transaction", "txrawresult-confirmations": "Number of confirmations of the block", "txrawresult-time": "Transaction time in seconds since 1 Jan 1970 GMT", "txrawresult-blocktime": "Block time in seconds since the 1 Jan 1970 GMT", - "txrawresult-blockindex": "Index of the containing block.", - "txrawresult-blockheight": "Height of the block the transaction is part of", + "txrawresult-blockindex": "The index within the array of transactions contained by the block", + "txrawresult-blockheight": "The height of the block that contains the transaction", "txrawresult-expiry": "The transacion expiry", // SearchRawTransactionsResult help. @@ -264,9 +264,12 @@ var helpDescsEnUS = map[string]string{ "searchrawtransactionsresult-txid": "The hash of the transaction", "searchrawtransactionsresult-version": "The transaction version", "searchrawtransactionsresult-locktime": "The transaction lock time", + "searchrawtransactionsresult-expiry": "The transacion expiry", "searchrawtransactionsresult-vin": "The transaction inputs as JSON objects", "searchrawtransactionsresult-vout": "The transaction outputs as JSON objects", - "searchrawtransactionsresult-blockhash": "Hash of the block the transaction is part of", + "searchrawtransactionsresult-blockhash": "The hash of the block the contains the transaction", + "searchrawtransactionsresult-blockheight": "The height of the block that contains the transaction", + "searchrawtransactionsresult-blockindex": "The index within the array of transactions contained by the block", "searchrawtransactionsresult-confirmations": "Number of confirmations of the block", "searchrawtransactionsresult-time": "Transaction time in seconds since 1 Jan 1970 GMT", "searchrawtransactionsresult-blocktime": "Block time in seconds since the 1 Jan 1970 GMT",