code: func createTxRawResult(chainParams *chaincfg.Params, mtx *wire.MsgTx,
  	txHash string, blkHeader *wire.BlockHeader, blkHash string,
  	blkHeight int32, chainHeight int32) (*btcjson.TxRawResult, error) {
  
  	mtxHex, err := messageToHex(mtx)
  	if err != nil {
  		return nil, err
  	}
  
  	txReply := &btcjson.TxRawResult{
  		Hex:      mtxHex,
  		Txid:     txHash,
  		Hash:     mtx.WitnessHash().String(),
  		Size:     int32(mtx.SerializeSize()),
  		Vsize:    int32(mempool.GetTxVirtualSize(btcutil.NewTx(mtx))),
  		Vin:      createVinList(mtx),
  		Vout:     createVoutList(mtx, chainParams, nil),
  		Version:  mtx.Version,
  		LockTime: mtx.LockTime,
  	}
  
  	if blkHeader != nil {
  		// This is not a typo, they are identical in bitcoind as well.
  		txReply.Time = blkHeader.Timestamp.Unix()
  		txReply.Blocktime = blkHeader.Timestamp.Unix()
  		txReply.BlockHash = blkHash
  		txReply.Confirmations = uint64(1 + chainHeight - blkHeight)
  	}
  
  	return txReply, nil
  }
docs: // createTxRawResult converts the passed transaction and associated parameters
  // to a raw transaction JSON object.