@@ -260,13 +260,13 @@ public IActionResult GetBlockHeader([FromQuery] string hash, bool isJsonFormat =
260260 /// <remarks>Requires txindex=1, otherwise only txes that spend or create UTXOs for a wallet can be returned.</remarks>
261261 [ Route ( "getrawtransaction" ) ]
262262 [ HttpGet ]
263- public async Task < IActionResult > GetRawTransactionAsync ( [ FromQuery ] string txid , bool verbose = false , string blockHash = null )
263+ public async Task < IActionResult > GetRawTransactionAsync ( [ FromQuery ] string trxid , bool verbose = false , string blockHash = null )
264264 {
265265 try
266266 {
267- Guard . NotEmpty ( txid , nameof ( txid ) ) ;
267+ Guard . NotEmpty ( trxid , nameof ( trxid ) ) ;
268268
269- if ( ! uint256 . TryParse ( txid , out uint256 trxid ) )
269+ if ( ! uint256 . TryParse ( trxid , out uint256 trxhash ) )
270270 {
271271 throw new ArgumentException ( nameof ( trxid ) ) ;
272272 }
@@ -278,7 +278,7 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
278278 }
279279
280280 // Special exception for the genesis block coinbase transaction.
281- if ( trxid == this . network . GetGenesis ( ) . GetMerkleRoot ( ) . Hash )
281+ if ( trxhash == this . network . GetGenesis ( ) . GetMerkleRoot ( ) . Hash )
282282 {
283283 throw new Exception ( "The genesis block coinbase is not considered an ordinary transaction and cannot be retrieved." ) ;
284284 }
@@ -289,12 +289,12 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
289289 if ( hash == null )
290290 {
291291 // Look for the transaction in the mempool, and if not found, look in the indexed transactions.
292- trx = ( this . pooledTransaction == null ? null : await this . pooledTransaction . GetTransaction ( trxid ) . ConfigureAwait ( false ) ) ??
293- this . blockStore . GetTransactionById ( trxid ) ;
292+ trx = ( this . pooledTransaction == null ? null : await this . pooledTransaction . GetTransaction ( trxhash ) . ConfigureAwait ( false ) ) ??
293+ this . blockStore . GetTransactionById ( trxhash ) ;
294294
295295 if ( trx == null )
296296 {
297- throw new Exception ( "No such mempool transaction. Use -txindex to enable blockchain transaction queries." ) ;
297+ return this . Json ( null ) ;
298298 }
299299 }
300300 else
@@ -307,7 +307,7 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
307307 throw new Exception ( "Block hash not found." ) ;
308308 }
309309
310- trx = chainedHeaderBlock . Block . Transactions . SingleOrDefault ( t => t . GetHash ( ) == trxid ) ;
310+ trx = chainedHeaderBlock . Block . Transactions . SingleOrDefault ( t => t . GetHash ( ) == trxhash ) ;
311311
312312 if ( trx == null )
313313 {
@@ -317,7 +317,7 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
317317
318318 if ( verbose )
319319 {
320- ChainedHeader block = chainedHeaderBlock != null ? chainedHeaderBlock . ChainedHeader : this . GetTransactionBlock ( trxid ) ;
320+ ChainedHeader block = chainedHeaderBlock != null ? chainedHeaderBlock . ChainedHeader : this . GetTransactionBlock ( trxhash ) ;
321321 return this . Json ( new TransactionVerboseModel ( trx , this . network , block , this . chainState ? . ConsensusTip ) ) ;
322322 }
323323 else
0 commit comments